Does the cron.hourly folderr work the same way as a cron job? Forgive me if I use any of the vocabulary wrong, I don't quite understand all of it yet. So if I make a symbolic link to proftpd in the cron.hourly directory it will first check if proftpd is running, then it will start it if it isn't?
Also, can I make a symbolic link that has commands attached to it? I wanted to put "/usr/local/apache2/bin/apachectl start" in the cron.hourly directory so it would check if apache was running or not and then start it if it wasn't.
Am I going about this all wrong?
Well, kind of. If you look in your /etc/crontab file, you will see that it is set up to run a program named "run-parts" on the various /etc/cron.* directories every so often. It will run "run-parts /etc/cron.hourly" at the beginning of each hour. What that run-parts script does is look in the directory it is given and run each program in there.
So if you make a link to proftpd in there, it will run it every hour, even if it is already running. This is probably not what you want, unless proftpd detects that another copy is already running and exits cleanly. You can probably do that and it will just log a message saying that the FTP server couldn't start up every hour.
A better solution is to write a little shell script that checks to see if proftpd is running or not (using ps or something), and runs it only if it is not already running. This won't fill up your log files.
You can't make a symlink with arguments. To do what you want with apachectl, you should create a shell script and put that in /etc/cron.hourly. Try something like this:
if $cmd status
then : # Apache is running
else $cmd start # Apache was stopped: start it again.
That should work, but check the exit code from "apachectl status" to see if I've gotten the test right. I don't remember just what it returns in various conditions.
|All times are GMT -5. The time now is 02:36 AM.|