首页 > 其他 > 详细

centos7添加开机自启任务

时间:2021-05-26 14:49:17      阅读:13      评论:0      收藏:0      [点我收藏+]

1.在/etc/init.d目录下创建开机自启脚本

[root@localhost ~]# cat /etc/init.d/php 
#!/bin/bash
# chkconfig:   - 85 15
#description: php.sh
bash /php/init.d.php-fpm start

其中第一行为指定脚本解释路径。

第二行为告诉chkconfig缺省启动的运行级以及启动和停止的优先级,如果某服务缺省不在任何运行级启动,那么使用 - 代替运行级。

第三行为该脚本描述或注释。

此三行必须有。

2.赋予该脚本执行权限

[root@localhost ~]# chmod a+x /etc/init.d/php

3.chkconfig增加该服务

[root@localhost ~]# chkconfig --add /etc/init.d/nginx

4.设定该服务为开机启动级别

[root@localhost ~]# chkconfig nginx on

5.此时如果脚本本身没问题,那么该服务已经可以通过service php start/stop/restart等命令进行启停了。

   可以reboot查看结果了

centos7添加开机自启任务

原文:https://www.cnblogs.com/liziaoligei/p/14813125.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!