Hi, I would like to have a cronjob running each hour checking on my critical services (httpd, inetd, etc). If one of 'em isn't running, it has to be started. Does anybody know how to do that? I can imagine something like ps aux|grep <string>|test, but then my knowledge of pipeing and shellcommands stop... Thanks, Rogier +---------------------------------+ | Rogier Maas | | icarus@guldennet.nl | | http://www.guldennet.nl~icarus/ | | ICQ# 2403780 | +---------------------------------+ -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
I've seen that many scripts in /sbin/init.d (don't know if all of them), have the "status" option. So you can trap those "OK" or "up" messages, meaning the service is working. --- sample --- # check for the lpd service to stay working... LPDSTATUS=`/sbin/init.d/lpd status | grep -c -e "OK" -e "up"` [ $LPDSTATUS -eq 0 ] && /sbin/init.d/lpd start --- end --- Hope this helps... - Nestor On Wed, 23 Feb 2000, Rogier Maas wrote:
Hi,
I would like to have a cronjob running each hour checking on my critical services (httpd, inetd, etc). If one of 'em isn't running, it has to be started.
Does anybody know how to do that? I can imagine something like ps aux|grep <string>|test, but then my knowledge of pipeing and shellcommands stop...
Thanks,
Rogier
+---------------------------------+ | Rogier Maas | | icarus@guldennet.nl | | http://www.guldennet.nl~icarus/ | | ICQ# 2403780 | +---------------------------------+
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
I don't suppose inetd has that function.. I was more thinking of something to really see if something is running or not, like I run setiathome. This program *definately* has no status function, but it shows up in ps. Would this do the trick: STATUS=`ps aux | grep -c -e "setiathome"` [ $STATUS -eq 0 ] && /usr/local/setiathome Or could I do: [ `ps aux | grep -c -e "setiathome"` -eq 0 ] && /usr/local/seti/setiathome ? I want to do the same with some other programs. btw: if the program itself has crashed, the PID file still remains. The status only checks for the PID file, so it always returns OK, even when it isn't running... Rogier Nestor Ruiz wrote:
I've seen that many scripts in /sbin/init.d (don't know if all of them), have the "status" option.
So you can trap those "OK" or "up" messages, meaning the service is working.
--- sample --- # check for the lpd service to stay working... LPDSTATUS=`/sbin/init.d/lpd status | grep -c -e "OK" -e "up"` [ $LPDSTATUS -eq 0 ] && /sbin/init.d/lpd start --- end ---
Hope this helps...
- Nestor
On Wed, 23 Feb 2000, Rogier Maas wrote:
Hi,
I would like to have a cronjob running each hour checking on my critical services (httpd, inetd, etc). If one of 'em isn't running, it has to be started.
Does anybody know how to do that? I can imagine something like ps aux|grep <string>|test, but then my knowledge of pipeing and shellcommands stop...
Thanks,
Rogier
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
Hi, On Wed, Feb 23, 2000 at 02:59 +0100, Rogier Maas wrote:
I don't suppose inetd has that function.. I was more thinking of something to really see if something is running or not, like I run setiathome. This program *definately* has no status function, but it shows up in ps. Would this do the trick:
STATUS=`ps aux | grep -c -e "setiathome"` [ $STATUS -eq 0 ] && /usr/local/setiathome
Or could I do:
[ `ps aux | grep -c -e "setiathome"` -eq 0 ] && /usr/local/seti/setiathome
?
Both work. A more straightforward version is /sbin/checkproc /path/of/executable || echo "It's not running" Ciao, Stefan -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
Stefan Troeger wrote:
Hi,
On Wed, Feb 23, 2000 at 02:59 +0100, Rogier Maas wrote:
I don't suppose inetd has that function.. I was more thinking of something to really see if something is running or not, like I run setiathome. This program *definately* has no status function, but it shows up in ps. Would this do the trick:
STATUS=`ps aux | grep -c -e "setiathome"` [ $STATUS -eq 0 ] && /usr/local/setiathome
Or could I do:
[ `ps aux | grep -c -e "setiathome"` -eq 0 ] && /usr/local/seti/setiathome
?
Both work. A more straightforward version is
/sbin/checkproc /path/of/executable || echo "It's not running"
Ciao, Stefan
HAHAH!! I KNEW it! Thanks Stefan! Rogier -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/
participants (3)
-
icarus@guldennet.nl
-
nruiz@essalud.sld.pe
-
stefan.troeger@wirtschaft.tu-chemnitz.de