linux系统服务
1.设置开机启动
vim /etc/rc.local
文件下加入需要开机执行的脚本,Linux开机就会自动执行
2.新增自己的系统服务
在/etc/init.d路径下新增自己的系统服务脚本
eg:
脚本如下:
#!/bin/bash
chkconfig: 2345 90 10
description: spr
. /etc/rc.d/init.d/functions
RETVAL=0
safe_kill_program()
{
ps_out=ps -ef | grep $1 | grep -v 'grep'
result=$(echo $ps_out | grep “
1
"
)
i
f
[
[
"
1") if [[ "
1")if[["result” != “” ]];then
killall -q -9 $1 > /dev/null
else
echo “.”
fi
}
start() {
cd /home/wangyong/ssl/zlog/
exec ./wy.sh &
echo “Starting spr :”
}
stop() {
killall -q -9 wy.sh > /dev/null
echo “Shutting down spr :”
}
case “$1” in
start)
stop
start
;;
stop)
stop
killall -q -9 wy > /dev/null
;;
restart|reload)
stop
start
;;
status)
status wy
RETVAL=0
;;
*)
echo $“Usage: $0 {start|stop|restart|status}”
exit 1
esac
exit $RETVAL