I'm try to make some shell script work like below.
#!/bin/bash while [ 1 ] do pid=`ps -ef | grep "sample.exe" | grep -v 'grep' | awk '{print $2}'` if [ -z $pid ]; then nohup ./run.sh > /dev/null & #./run.sh is shell script for run 'sample.exe' file fi usage=`ps -ef | grep "sample_watcher.sh" | grep -v 'grep' | awk '{print $2}'` if [ -z $usage ]; then $kill $(ps aux | grep "sample_watcher.sh"| awk '{print $2}') fi sleep 5 done "sample_watcher.sh" 15L, 491C this sh = "sample_watcher.sh". and this will work find sample.exe is runnig or not.
and if not running, then start run.sh = start up 'sample.exe'
and last part
if "sample_watcher.sh"is already run. then kill "sample_watcher.sh".
only one "sample_watcher.sh" should be run.
Is there better way to do?
Thanks.
flockthere's alsowatershed.