Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-12-2002, 01:20 AM
|
#1
|
Member
Registered: Jun 2002
Location: Los Angeles, Ca, USA
Distribution: Mandrake 9.1
Posts: 82
Rep:
|
program to check to make sure a process is running?
I have a fairly new server up and running which has a RealServer installed on it. It works fine but every couple of weeks, RealServer crashes and I have to manually start it again. Is there a program that will automatically check the process list and let me know if "rmserver" is still running and if it isn't, email me?
Of course this does not solve my RealServer problems but at least I'll know when it crashes right away.
Any suggestions are appreciated,
Jon
|
|
|
08-13-2002, 11:27 AM
|
#2
|
Member
Registered: Apr 2002
Location: Denver
Distribution: SuSe,RedHat,Mandrake,
Posts: 109
Rep:
|
Hi IceNineJon,
No sure how proficient you are in creating scripts but in your place I'd create one and put it as a cron to execute every so often.
Here is the pseudo code for it.
# check if rmserver is running.
if running=yes # to check this you can use ps
do nothing
else
e-mail system admin.
fi
You can also configure the /var/sys.log file for this task.
Good luck!

|
|
|
08-13-2002, 01:27 PM
|
#3
|
Member
Registered: Jun 2002
Location: Los Angeles, Ca, USA
Distribution: Mandrake 9.1
Posts: 82
Original Poster
Rep:
|
abrakadabra: thanks for the idea but unfortunately I'm not very proficient with linux scripting at the time but maybe it's a good time to learn then
Thanks for your input,
Jon
|
|
|
08-13-2002, 02:04 PM
|
#4
|
Moderator
Registered: May 2001
Posts: 29,417
|
# in /etc/crontab:
# this checks every 10mins
*/10 * * * * root /etc/cron.daily/checkrealserver.cron
#!/bin/sh
# this is /etc/cron.daily/checkrealserver.cron, chmod 0750
email=<insert address here>
progname=rmserver
if [ "$(/sbin/pidof $progname)" = "" ]; then echo "rmserver found down on $(date +%m-%d-%Y)" | mail -s "$progname on $(hostname) down at $(date)" $email; fi
Last edited by unSpawn; 08-13-2002 at 02:05 PM.
|
|
|
08-13-2002, 02:30 PM
|
#5
|
Member
Registered: Jun 2002
Location: Los Angeles, Ca, USA
Distribution: Mandrake 9.1
Posts: 82
Original Poster
Rep:
|
Dang unSpawn...you make it look so easy  . Thanks, it's working like a charm  .
Now, is there any way to make it so it won't email me every ten minutes while it's down (for example, let's say it goes down at 8 PM and I don't check my email until midnight...I'll have 24 warning messages)? If it's too much trouble, don't worry about it, I doubt the little text messages will fill my 75 MB mail queue  .
Thanks again!,
Jon
Last edited by IceNineJon; 08-13-2002 at 02:31 PM.
|
|
|
08-14-2002, 08:43 AM
|
#6
|
Moderator
Registered: May 2001
Posts: 29,417
|
Well, there's two ways. First you could tweak the crontab entry to a higher check interval, or we could add an interval to the checkscript. Then again that doesn't fix what you *should* fix, and that's rmserver b4rfing up. Ever considered running strace on it?
Below you'll find a stupid example of how you could tweak a limit per day/hour. It'll check the file for the last time it was run, and if the interval has passed it'll fire off a mail.
We need to add another file, /var/run/checkrealserver make it 0640 to the user.
#!/bin/sh
# this is /etc/cron.daily/checkrealserver.cron, chmod 0750
email=<insert address here>
progname=rmserver
limitf=/var/run/checkrealserver
limitc="+%<d|H>" # d=once daily, H=once hourly, mind you, hourly is caps
if [ ! -f /var/run/checkrealserver ]; then echo "We can't do limiting because we miss $limitf" | mail -s "$progname check error" | mail $email; else limit=$(grep $limitf -e "$(date $limitc)")
if [ "$(/sbin/pidof $progname)" = "" ]&&[ ! "$(date $limitc)" = "$limit" ]; then echo "rmserver found down on $(date +%m-%d-%Y)" | mail -s "$progname on $(hostname) down at $(date)" $email; echo $(date $limitc) > $limitf; fi
# Hell, you could even bashexercise and add a multiplier, like once every 4 dys/hrs...
|
|
|
08-14-2002, 11:05 PM
|
#7
|
Member
Registered: Jun 2002
Location: Los Angeles, Ca, USA
Distribution: Mandrake 9.1
Posts: 82
Original Poster
Rep:
|
Again, thank you for your help...a few questions about your last post:
1) I'd never heard of strace before so I did a google search for it and found the homepage. The page has kernel patches but they're for 2.2.x and I have 2.4.x...does this mean it's not necessary to patch my kernel or do I still need to but the patches are behind?
2) I'm a little confused what this script does. Does it check to see if rmserver is down...if so, it checks to see how much time has passed since an email was last sent? If so, perfect  . If not, can you elaborate on what it does?
3) You said above that we need to add another file...I assume that means to leave the other cronjob in the crontab? If so, how do these scripts relate to one another?
Thanks again for your help!,
Jon
Last edited by IceNineJon; 08-14-2002 at 11:08 PM.
|
|
|
08-06-2003, 02:07 PM
|
#8
|
LQ Newbie
Registered: Aug 2003
Location: Pittsford, NY
Distribution: Mac OS X 10.2.6
Posts: 1
Rep:
|
Hey,
I found this thread doing a Google search. For whatever reason, my mail server decides to shut itself down whenever somebody logs out of the system. I don't know why. So I wanted to make a cron entry to restart it if it does that, and I tried following these directions.
I had to make my own pidof program, because apparently OS X doesn't have one, but I did and it works just fine. The problem is, the cronjob doesn't appear to work.
My root crontab looks like so:
*/1 * * * * root /etc/cron.daily/checkmailserver.cron
(I want it to check every 1 minute)
And checkmailserver.cron looks like so:
#!bin/sh
progname=WSMailboxServer
if [ "$(/sbin/pidof $progname)" = "" ]; then /Applications/4DWebSTAR/StartupItem/4DWebSTAR/4DWebSTAR; fi
It doesn't seem to work; the mail server shuts down and nothing happens -- it is never restarted. Just for the hell of it, I made the checkmailserver.cron file +x and then tried to execute it, and I got a command not found.
Anyone have any ideas?
|
|
|
All times are GMT -5. The time now is 01:52 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|