700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > linux实现开机自启动脚本

linux实现开机自启动脚本

时间:2021-06-15 11:31:36

相关推荐

linux实现开机自启动脚本

方法一 修改/etc/rc.local

修改好脚本,在任意目录启动时正常执行在/etc/rc.local的末尾添加一行以绝对路径启动脚本的行

vim /etc/rc.local

#!/bin/sh## This script will be executed *after* all the other init scripts.# You can put your own initialization stuff in here if you don't# want to do the full Sys V style init stuff./bin/bash /server/scripts/test123.sh >/dev/null 2>/dev/null

保存并重启

方法二 chkconfig管理

init.d目录下都为可执行程序,他们其实是服务脚本,按照一定格式编写,Linux 在启动时会自动执行,类似Windows下的服务 用root帐号登录,vi /etc/rc.d/init.d/mystart,追加如下内容:

#!/bin/bash#chkconfig:2345 80 05 --指定在哪几个级别执行,0一般指关机,# 6指的是重启,其他为正常启动。80为启动的优先级,05为关闭的优先机#description:mystart service#!/bin/bash# chkconfig: 3 88 88/bin/bash /server/scripts/test123.sh >/dev/null 2>/dev/null

chmod +x /etc/init.d/mystart# 添加到chkconfig,开机自启动chkconfig --add mystart# 查看服务进程的状态chkconfig --list mystart# chkconfig管理中删除chkconfig --del mystart

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。