program to check to make sure a process is running?
Linux - SoftwareThis 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.
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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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 .
Last edited by IceNineJon; 08-13-2002 at 02:31 PM.
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.
# this is /etc/cron.daily/checkrealserver.cron, chmod 0750
email=<insert address here>
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...
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!,
Last edited by IceNineJon; 08-14-2002 at 11:08 PM.
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:
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.