What's the best way to run a conitnuous program at boot?
Hi - I need to run a program at boot. It is a perl script that talks to a serial device. The program needs to run forever (never stops). I see there are several ways to start such a program, but can't understand which is the best, especially considering that the program runs forever (not sure if that affects the decision).
I see there is: -start it in rc.local -start it in an init.d script -start it with cron -make a daemon No matter what method is used, I am concerned as to whether I need to use an ampersand to run the program in the background so it will detach from the caller so that the caller does not get blocked (dunno if that matters). So I'm leaning to just using cron. If so, do I have it call a script with the ampersand (does it matter). Thanks |
It would have been great if you had posted your distro, policy as where to put a program run a boot time varies from one distro to the other.
rc.local is a good candidate I would say. The cleanest way to do this is like this: - create a start/stop/restart script. Plenty of examples simple and complicated in init.d. You should be able to pick one and use it. - it is best to call your script from the script mentioned above, and background it with '&' - be sure your script does not produce output, or redirect it to /dev/null - store the pid of the backgrounded process, and store the pid (in a file) so you are able to stop and restart the process. (you don't want to reboot your computer for that, do you?) jlinkels |
Quote:
|
Once you created the script in init.d, don't forget to run update-rc.d to link the correct runlevels to the script. If Ubuntu works the same as Debian.
jlinkels |
All times are GMT -5. The time now is 06:36 PM. |