On Fri, 21 Jan 2005 11:17, Andrew Errington wrote: > Hello, > > I have a "style" question regarding a process that I wish to run all the > time. > > Basically, my weather data collection comprises two programs. One is a > program to query the temperature sensor. The other is a Perl script to > query the wind sensor. Both programs output to a text file, then a cron > job generates graphs from the data in the text file. > > At the moment I have the programs running in two terminal windows. I want > to automate them so they will: > > a) Run automatically when the server is rebooted (with a current uptime of > 228 days I am loathe to test that...) > b) Restart automatically if they ever stop running > > I am sure there are a number of common techniques for this, but is there a > 'best' one? Should the programs run as root, or run as me? > > A simple solution might be to run a cron job every hour that checks whether > the process is running, and if not, starts it up. That can be set up by > me, and therefore the process runs as me, and covers both situations above. > If the process runs as root then I need to be root to kill it if I ever > want to change it. > > Any clues? You don't mention which distribution you are running, we can only reply in general terms.
The quick and dirty way is to make an entry into the file provided for the purpose. There will be a file in the /etc/rc.d directory tree ( RedHat et al ) into which you can put commands to run at the end of the start-up sequence. The file is called /etc/rc.d/rc.local on mandrake ( 8.? ) and Other dists. will use something similar. imho ( as a purist ) you should run these daemons using their own user. The data can then be stored in their home directory also. You might like to save the pids in the directory /var/run It's then easy to check that they are still running unambiguously, and to kill them off simply. -- Sincerely etc., Christopher Sawtell
