Centos7下shell脚本添加开机自启动


添加开机自启脚本,注意都需要用绝对路径

psubscribe.sh脚本中的内容:

nohup /usr/bin/php -f /data/aliyun51015cn/redisChannel/psubscribe.php > psubscribe.log &

 

1、赋予脚本可执行权限(/opt/script/psubscribe.sh是你的脚本路径)

# chmod 777 /data/aliyun51015cn/redisChannel/psubscribe.sh

2、打开/etc/rc.d/rc.local文件,在末尾增加如下内容

# echo "/data/aliyun51015cn/redisChannel/psubscribe.sh" >> /etc/rc.d/rc.local

3、在centos7中,/etc/rc.d/rc.local的权限被降低了,所以需要执行如下命令赋予其可执行权限

# chmod +x /etc/rc.d/rc.local


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM