Date: Wed, 23 Apr 1997 17:50:46 -0500 From: Lee Crites <leec@adonai.net> To: Dan Wolfe <DWolfe@ZYGA.com> Cc: "'questions@freebsd.org'" <questions@freebsd.org>, "'dsmith@zyga.com'" <dsmith@ZYGA.com> Subject: Re: Cron jobs Message-ID: <335E9246.178D@adonai.net> References: <01BC4FF0.6D7EC0A0@dans-zyga-pc.zyga.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Dan Wolfe wrote:
>
> FreeBSD Users:
>
> Has anyone written a script to periodically check if a particular process is running, and if not, restart it?
>
> -Dan Wolfe
> ZYGA Corporation
Try this script on for size, it's working for me, anyway...
#!/bin/csh -f
#
# check for program and start it if it is not found
#
echo "Check/starting process"
#
# program name should be $1
#
if ($1 == "") then
echo "usage: $0 program-to-check"
exit
endif
set STR = $1
echo " -- starting "$STR
#
# see if it is running and start it if needed
#
if (`ps -aux|grep -v grep|grep -c $STR` == 0) then
echo " -- starting process"
$STR >>& /dev/null &
else
echo " -- process already running"
endif
#
# done
#
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?335E9246.178D>
