Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a process 1

Status
Not open for further replies.

sramki

Programmer
May 8, 2001
27
IN
hi all

how do i run a process for the first time at the start up and then it shd wake up every 5 or 10 minutes and once it is complete it shd go to sleep .
could any one of u give me an idea about that

with regards
ramki
 
You could try something like this crontab entry:

00,05,10,15,20,25,30,35,40,45,50,55 * * * 0-6 <program>

where <program> is the pathname of your process. Alter the 00, 05, 10 etc to suit the time interval you want (this example is for every 5 minutes).

To run the program on startup create an S99<program> in your /etc/rc2.d directory. However, the above cron would kick in within 5 minutes of startup if that's good enough.

Hope this helps.
 
You can also call the script in you /etc/inittab and have respawn. I also would recommend the cron way though. Easier to control (start/stop/change) without messing around in the inittab. I have run several scripts this exact way, executing every 5 minutes during specified time frames and on specified days. Remember, amateurs built the Ark, professionals built the Titanic.
 
hi ken and prv

Thanks for ur support .
Hey is there an option in respwan to respawn at a particular time if it is there i will be useful .

Anyway thanks for the idea .

If i can help u by any means
contact

s_ramki@rediffmail.com

with regards
ramki
 
The respawn action is based upon the init command and you cannot specify the timing of it. The respawn means to restart it if it dies. Here's some info:


The reason I prefer the cron method, as described by KenCunningham is the easier and safer control of your job. Messing around in the /etc/inittab can be dangerous. IBM does not recommend changing it with vi, but to use the chitab and mkitab commands. I personally seen some scripts go awry with respawn, particularly if your coding is not just right. Plus in cases where you are having some system problem, like with CPU usage or poor performance, you can get inundated with trying to kill stray processes and at the same time they are trying to respawn. So, just a warning, be careful.

The cron entry for your script is really easy to set the time interval (every 5 minute, 10 minutes, 30 etc), as well as the days and range of hours that you want it to run. And it it so much easier and safer to start and stop by just commenting it out of the crontab. Remember, amateurs built the Ark, professionals built the Titanic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top