Verifying a program is running by cron job, if not starting it.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
Verifying a program is running by cron job, if not starting it.
Like the title says I have a program that I want to make sure is running 24/7. Every hour I want to "check" if it is running using a cron job, and if so then nothing, but if it isn't then I want to start it. Currently I have it setup using this command:
and you can of course guess the problem... I had 20 processes of the same thing running in no time So how can I do it so it only starts an instance if there isn't one running already ?
i'd have to assume a typo... check that this has the same effect for you:
Code:
[root@kermit ~]# [ "$(/sbin/pidof bash)" ] || echo BASH IS NOT RUNNING!
[root@kermit ~]# [ "$(/sbin/pidof bashxxx)" ] || echo BASHXXX IS NOT RUNNING!
BASHXXX IS NOT RUNNING!
so a process that clearly does exist is found, so the echo is not executed. when a fictious program is requested and not found, the echo command fires. you may well have whitespace issues or such like.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.