复制自定义的shell文件到 /etc/init.d/ 目录下
设置shell 文件的 一些配置信息 ,在#注释中配置
chkconfig --add name.service 添加服务
chkconfig name.service on/off 开机启动或者关闭
service name.service start/stop 开启服务或者关闭
chkconfig --del name.service 删除服务
在这个shell的脚本中某些 环境变量 没有,需要自己加上。
# chkconfig: 2345 85 15 #启动级别0~7 开启优先级,关闭优先级
# description: redis service.
echo "input params $# "
echo $1
if [ $1 ]
then
if [ $1 = "start" ];then
/usr/local/bin/redis-server /home/application/redis/redis.conf
echo "start OK"
elif [ $1 = "stop" ];then
/usr/local/bin/redis-cli shutdown
echo "stop OK"
else
echo "please use: service redis start"
fi
fi