centos 7 /etc/rc.d/init.d/ 开机自动执行脚本

把“脚本文件”放在/etc/rc.d/init.d目录下:

添加脚本到开机自动启动项目中

cd /etc/rc.d/init.d
chkconfig --add xxx.sh
chkconfig xxx.sh on

注:xxx.sh为脚本文件

脚本文件中必须包含以下俩项:

  #chkconfig: 2345 10 90

  #description: ping10

第一行告诉chkconfig缺省启动的运行级以及启动和 停止的优先级。
第二行对服务进行描述,可以用 跨行注释。

原文地址:https://www.cnblogs.com/yyxianren/p/12395485.html