cancel
Showing results for 
Search instead for 
Did you mean: 

script

STL
Occasional Advisor

script

Hi,
how i check status of my process with a script?
ps -ef|grep pippo
how i check if pippo is running and then if not running start them??
5 REPLIES
Sergejs Svitnevs
Honored Contributor

Re: script

You can put you script in the /etc/inittab.

Add to the bottom of inittab file the string:
xx::respawn:`
then execute:
telinit q

If script dies, the init process will restart your process automatically.

Regards,
Sergejs
STL
Occasional Advisor

Re: script

in my script insert only the start of my process??
Ivan Ferreira
Honored Contributor

Re: script

You can use something like this in cron also:

RUNNING=`pgrep pipo|wc -l`

if [ $RUNNING -eq 0 ]; then

mail -s "PIPO is not running" root < /dev/null
# Start the application
/path/to/pipo

fi
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
STL
Occasional Advisor

Re: script

when i use the command telinit q the process start, but then if i kill the process, this not restart.
why???
Mark Ellzey
Valued Contributor

Re: script

Carlo,

If you kill the process and it does not restart, check your /etc/inittab file. I was just running a test and set up the inittab like this:

7:2345:/home/myid/myscript

and it did not restart. (myscript is just a loop that echoes date > log.file)

However, when I change the inittab to this:

7:2345:/bin/bash /home/myid/myscript

it worked fine. Everytime I killed it, it restarted immediately.

So, check your inittab entry.

Regards,
Mark