Linux script to restart process running out of inittab

Can someone help me with writing a script to restart a process running out of the inittab.
Any links or suggestions would be great.



Thank you.
cbonesAsked:
Who is Participating?
 
slyongConnect With a Mentor Commented:
use crontab to schedule the restart of the application (shutdown and startup).  Login as the user you can stop and start the application.  Then on the command line type:

$ crontab -e
10 0 * * * /path/to/script/restartscript.sh

The above will run restartscript.sh as 12:10am every night.  In your restartscript.sh you would need to issue the command to kill the process and restart it:

#!/bin/bash
/usr/bin/killall processname
/path/to/applicationstartup

**Note that in the restartscript.sh you have to use the fullpath.

0
 
slyongCommented:
Hi cbones,

Could you let us know what is the process that you want to restart and the relevant entry in the inittab?
0
 
ravenplCommented:
run the application from inittab as following
c1:2345:respawn:/path/to/application

then just kill the application if You want to restat it (init will respawn it)
killall application
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
cbonesAuthor Commented:
One of our software venders has a java process running in the inittab. They can't seem to figure out why it crashes so often.  The only way to get it running again is to kill the process manually and restart it.  I wanted to have a script run every night to stop the process and then restart it.  This way there would be no issues with the process stopping.

It seems when it is running for a few days it hangs up.  I believe the restart would help stop this issue.


Thanks.

0
 
cbonesAuthor Commented:
Thank you for all your help.  I am going to give it a shot.


Thank you.
0
 
ravenplCommented:
What is has to do with init/inittab?
But I guess it works...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.