以ubuntu开机启动reids为列
1.创建sh脚本
头部必须增加
#!/bin/sh ### BEGIN INIT INFO # Provides: OSSEC HIDS # Required-Start: $network $remote_fs $syslog $time # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: OSSEC HIDS ### END INIT INFO
原代码
#!/bin/sh ### BEGIN INIT INFO # Provides: OSSEC HIDS # Required-Start: $network $remote_fs $syslog $time # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: OSSEC HIDS ### END INIT INFO cd /home/rootplt/redis/redis-3.2.6 ./src/redis-server ./redis.conf exit 0
2.
文件上传到 /etc/init.d 目录
给执行文件授权
sudo chmod +x xxx.sh
3.注册开机启动
sudo update-rc.d redisqd.sh defaults 99
99是开机启动的顺序
没有错误提示,标示完成。
4.验证
立即重启
sudo shutdown -r now
重启后查看是否正常启动
ps -e|grep redis
有reids运行的进程标示启动成功
移除开机启动
sudo update-rc.d -f xxx.sh remove