S
skywater007
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠好,我有个java程序,helloworld.java,我想做个守护进程,当它吊死的时候,重新启动:我写了如下,但是不行
#!/bin/bash
pidmontst=`ps -ef | grep '/helloworld/' | grep 'classpath' | sed -e 's/^root *//' -e 's/ .*//' | head -1`
if [ "X$pidmontst"
= "X"
];
then
echo "Sorry, CRM not Exist! Restart it!"
java helloworld&
else
echo
# echo "CRM is running!"
fi
保存为run.sh
#./run.sh
Sorry, CRM not Exist! Restart it!
#ps -ef | grep helloworld
root 4093 1 8 23:22 pts/6 00:00:01 java helloworld
root 4117 3402 0 23:22 pts/7 00:00:00 grep LoadCrmData
但是我再运行一次,还是多了一个线程
#./run.sh
Sorry, CRM not Exist! Restart it!
#ps -ef | grep helloworld
root 4093 1 8 23:22 pts/6 00:00:01 java helloworld
root 4108 1 10 23:22 pts/6 00:00:01 java helloworld
root 4117 3402 0 23:22 pts/7 00:00:00 grep helloworld
说明我的守护程序不成功啊,各位大侠,应该怎么写啊?
#!/bin/bash
pidmontst=`ps -ef | grep '/helloworld/' | grep 'classpath' | sed -e 's/^root *//' -e 's/ .*//' | head -1`
if [ "X$pidmontst"
= "X"
];
then
echo "Sorry, CRM not Exist! Restart it!"
java helloworld&
else
echo
# echo "CRM is running!"
fi
保存为run.sh
#./run.sh
Sorry, CRM not Exist! Restart it!
#ps -ef | grep helloworld
root 4093 1 8 23:22 pts/6 00:00:01 java helloworld
root 4117 3402 0 23:22 pts/7 00:00:00 grep LoadCrmData
但是我再运行一次,还是多了一个线程
#./run.sh
Sorry, CRM not Exist! Restart it!
#ps -ef | grep helloworld
root 4093 1 8 23:22 pts/6 00:00:01 java helloworld
root 4108 1 10 23:22 pts/6 00:00:01 java helloworld
root 4117 3402 0 23:22 pts/7 00:00:00 grep helloworld
说明我的守护程序不成功啊,各位大侠,应该怎么写啊?