Go Back   Pro/Forums > ProCooling Geek Bits > Random Nonsense / Geek Stuff
Password
Register FAQ Members List Calendar Chat

Random Nonsense / Geek Stuff All those random tech ramblings you can't fit anywhere else!

Reply
Thread Tools
Unread 10-02-2002, 10:14 AM   #1
Joe
The Pro/Life Support System
 
Joe's Avatar
 
Join Date: Dec 1999
Location: Denver, CO
Posts: 4,041
Default 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!!!
__________________
Joe - I only take this hat off for one thing...

ProCooling archive curator and dusty skeleton.
Joe is offline   Reply With Quote
Unread 10-02-2002, 11:48 AM   #2
Arcturius
Cooling Savant
 
Join Date: Aug 2001
Location: Chippewa Falls, Wisconsin
Posts: 294
Default

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 :|

Last edited by Arcturius; 10-02-2002 at 11:54 AM.
Arcturius is offline   Reply With Quote
Unread 10-02-2002, 11:51 AM   #3
Joe
The Pro/Life Support System
 
Joe's Avatar
 
Join Date: Dec 1999
Location: Denver, CO
Posts: 4,041
Default

awesome I will try it out tonight!!! thanks!!
__________________
Joe - I only take this hat off for one thing...

ProCooling archive curator and dusty skeleton.
Joe is offline   Reply With Quote
Unread 10-02-2002, 05:30 PM   #4
Arcturius
Cooling Savant
 
Join Date: Aug 2001
Location: Chippewa Falls, Wisconsin
Posts: 294
Default

Oh, BTW, the above will run the script every 10m, but being what your occupation is, I'm sure you knew that.

Have fun!
Arcturius is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:56 PM.


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...