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
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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.