在CentOS8中编写开机自运行脚本

首先切换到/etc/init.d目录下

cd /etc/init.d

新建shell脚本

vim test.sh

脚本文件test.sh内容如下:

#!/bin/sh
#chkconfig:2345 90 10
#description: 描述#下面写命令
cd /usr/local/test-server/bin
./start.sh

保存退出

为这个脚本加上可执行权限

chmod +x test.sh

至此,可将此脚本加入chkconfig命令进行管理

chkconfig --add test.sh


设置该脚本为开机自运行

chkconfig test.sh on

OK完成,现在该脚本在机器启动后自动运行

若要移除该自启动脚本,依次执行如下两句即可

chkconfig test.sh off

chkconfig --del test.sh
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容