在/etc/rc.d/init.d中编写lan-monitor可执行脚本如下:
#!/bin/bash
# chkconfig:235 98 98
# description start or stop lan-monitor
start()
{
echo "start LAN-Monitor"
/home/hexiaowei/program/monitor/./lan-monitor &
exit 0;
}
stop()
{
pkill lan-monitor
echo "stop lan-monitor"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "usage:$0 start|stop|restart"
exit 0;
esac
注意上面的
# chkconfig:235 98 98
这个在执行chkconfig --add lan-monitor命令时用到
235表示运行级别2、3、5
98分别表示S98、K98
执行chkconfig --add lan-monitor
最后在rc2.d rc3.d
rc5.d中生成S98lan-monitor
在其它rc*.d中(rc0.d rc1.d
rc4.d
rc6.d)生成K98lan-monitor
#!/bin/bash
# chkconfig:235 98 98
# description start or stop lan-monitor
start()
{
echo "start LAN-Monitor"
/home/hexiaowei/program/monitor/./lan-monitor &
exit 0;
}
stop()
{
pkill lan-monitor
echo "stop lan-monitor"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "usage:$0 start|stop|restart"
exit 0;
esac
注意上面的
235表示运行级别2、3、5
98分别表示S98、K98
执行chkconfig --add lan-monitor
最后在rc2.d
在其它rc*.d中(rc0.d