I need someone to help me write a cron job!!
OK what i basicly need done, is something to monitor the httpd service on an hourly basis.
Basically I need it to do a “/sbin/service httpd status” and if the response is “httpd is stopped...” then run a “/sbin/service httpd start” I am a dumbshit when it comes to writing my own scripts ( I can edit other people stuff rather easily though ;)) so I need some help with making the job file that I can drop into cron.hourly on the server. There is a glitch with php, and the management software on the server that causes the HTTPD service to get all confused durring a graceful restart. ( cause it attempts multiple restarts at once and .. well that doesn't work) Any help would be appreciated!!! |
put this in cron:
*/10 * * * * root perl /pathToTheScript/httpdwatch.pl And here's the script: #!/usr/bin/perl #================================================= =================httpdwatch.pl # Objective: Periodically check in on httpd and start if necessary # Inputs: None # Outputs: None # History: # Programmer: Date: Modification: # -------------- ---------- ------------------------------------------------- # Rob Burgess 10/02/2002 Original version #================================================= ============================== open(serviceStatus, "/sbin/service httpd status|"); $httpdStatus=<serviceStatus>; chomp $httpdStatus; close(serviceStatus); if( $httpdStatus =~ /stopped/ ){ system("/sbin/service httpd start&"); } elsif( $httpdStatus =~ /running/ ){#OK so far... } else{ print("Something is very wrong...(httpdwatch.pl)\n"); }#==============================EOF=============== =============================== #edit: made some readability improvements #edit: and a syntax error fix :| |
awesome I will try it out tonight!!! thanks!!
|
Oh, BTW, the above will run the script every 10m, but being what your occupation is, I'm sure you knew that. :D
Have fun! |
All times are GMT -5. The time now is 03:02 AM. |
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
(C) 2005 ProCooling.com If we in some way offend you, insult you or your people, screw your mom, beat up your dad, or poop on your porch... we're sorry... we were probably really drunk... Oh and dont steal our content bitches! Don't give us a reason to pee in your open car window this summer...