LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-18-2003, 01:13 AM   #1
Raw Kuts
LQ Newbie
 
Registered: Jul 2003
Location: San Diego, CA
Distribution: Mandrake 9.1
Posts: 7

Rep: Reputation: 0
cron.hourly question


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?
 
Old 08-18-2003, 12:34 PM   #2
MacKtheHacK
Member
 
Registered: Jul 2003
Location: Boston, MA, USA
Distribution: RedHat, SuSE, Gentoo, Slackware, Mandrake ...
Posts: 111

Rep: Reputation: 15
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:

#! /bin/sh
cmd=/usr/local/apache2/bin/apachectl
if $cmd status
then : # Apache is running
else $cmd start # Apache was stopped: start it again.
fi

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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
shutup cron.hourly mail reports darkleaf Linux - Software 4 06-27-2005 10:28 AM
Hourly Crontab Setup gbkyle Linux - Newbie 2 10-06-2004 08:54 PM
Mandrake 10.0 = Hourly Crashes jjthebear Linux - Hardware 13 08-28-2004 11:59 AM
How do I run/write an hourly cron? KoopaTroopa Linux - Newbie 1 08-16-2003 06:12 PM


All times are GMT -5. The time now is 03:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration