LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   "Check if running" Script... (https://www.linuxquestions.org/questions/linux-software-2/check-if-running-script-21621/)

bfloeagle 05-23-2002 07:49 AM

"Check if running" Script...
 
I'm using a webcam program (the one included with xawtv) that is obviously hosting my webcam to the internet. The only problem is that after about 3 hours, the program terminates... I'm not sure why...

I'm looking for a script that would run every hour or so that looks to see if the webcam program is up and running; if it is not, the script would start it. Anyone know of one?

Andy

hanzerik 05-23-2002 08:06 AM

setup a cron job:

0 * * * * /usr/bin/xawtv-program-name -nice 19 > /dev/null 2> /dev/null

This cron job will attempt to start the program at the top of every hour.
If it is already running, the next invocation will do nothing.
If the program is not running, it will be started.
For more information on cron jobs see the crontab(1) manual page.

acid_kewpie 05-23-2002 08:12 AM

you wouldn't find an existing script to do that... cos it's just so damn easy and simple to write yourself!

e.g.

if [ `ps ax | grep webcam | wc -l` -le 0 ]
then
webcam &
fi

set that up as a cron job and it'll be fine. OR... i' suggest a better way to run the whole thing:

while [ 1 = 1 ]
do
webcam
done

auto reload when it dies....


All times are GMT -5. The time now is 02:42 PM.