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