您的位置:首页 > 其它

ubuntu添加开机启动项

2013-09-10 21:54 239 查看
1)我想写一个开机自动跑服务程序的脚本

vi /etc/init.d/watchDog.sh

#!/bin/sh

while [ 1 ]

do

magicServerId=`ps -ef | grep -F /home/wt/magicServerTotal/MagicServerTotal.out|grep -v grep|awk '{print $2}'`

if [ $magicServerId ]

then

echo "/home/wt/magicServerTotal/MagicServerTotal.out is running pid is" $magicServerId

else

nohup /home/wt/magicServerTotal/MagicServerTotal.out &

fi

sleep 5

done

2)该脚本程序开机时,自动添加的后台运行

vi /etc/rc.local

添加一行

nohup /home/wt/magicServerTotal/MagicServerTotal.out &

3)重启机器,即可达到目的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: