LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Simple script - check if program is running (https://www.linuxquestions.org/questions/linux-server-73/simple-script-check-if-program-is-running-621741/)

KrzysieQ 02-17-2008 01:30 AM

Simple script - check if program is running
 
Hi, I have small problem, I have a server with ssh access (RSA keys authentication - so without password). I need a check on small period of time, if a specific program is running - if not - run it in screen.

It may be a simple bash script which I could put in my crontab.

Anybody can help me ?
I read a topic:
http://www.linuxquestions.org/questi...unning-383958/
but I don't have an idea, how to use it with ssh, because I can't run it on that server.

Sorry for my poor English.

budword 02-17-2008 02:24 AM

You could gin up a quick script to run "ps -A" then grep <STDOUT> for the name of the program you are looking for.

David

KrzysieQ 02-17-2008 02:36 AM

Any example ?
I would be glad :)

Deleriux 02-17-2008 07:48 AM

Code:

! pgrep someprogram &>/dev/null && screen -s /path/to/someprogram


All times are GMT -5. The time now is 08:58 PM.