Is there anyone who can help me understand how to use cron to do events at certain times. Thanks Ray Booysen
ill try if you want to something to run every hour or day or week or month, just write a little script and put it in /etc/cron.daily or /etc/cron.hourly, etc. the script can be anything, say if you want to set your system time via ntp every day, just do this echo "ntpdate -b -s some.ntp.server" > /etc/cron.daily/settime.cron chmod 700 /etc/cron.daily/settime.cron now, if you want to do things every minute or every 12 minutes or every 3rd monday or something like that, you will use the crontab file /etc/crontab the syntax for crontab entries are like * * * * * /path/to/script/to/run where the *'s represent minute of hour hour of day day of month month day of week or i think thats how it goes so if you want to run a script every 10 minutes, you could do something like * */10 * * * root /home/dog/myscript.sh On Mon, 27 Aug 2001, Ray Booysen wrote:
Chad Whitten Network/Systems Administrator Nexband Communications chadwick@nexband.com
On Monday 27 August 2001 09:45 am, Ray Booysen wrote:
Here's a simple example: 1) Issue: crontab -e (as user or root as appropriate) 2) Edit the file shown (which might be empty to start) Here are a few examples from mine: PATH=/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/opt/bin:/opt/teTeX/bin:/opt/kde/bin: LD_LIBRARY_PATH=/usr/lib:/usr/local/orexx/lib:/opt/kde/lib:/usr/local/bin: MAILTO="" # min hr day month dayofweek #0-59 0-23 0-31 0-12 0-7 (0 is Sun) #Run Tripwire at 15 after noon every day 15 12 * * * /usr/local/Tripwire_221/bin/runtw #update the clock every day at Noon (let NTP try for awhile) 0 12 * * * rdate -s time-b.nist.gov 1 12 * * * hwclock --systohc # min hr day month dayofweek #run klogd once an hour 1 0-23 * * * klogd -o #Ping the world every 5 minutes 1-59/5 0-23 * * * ping somewhere.edu #Run LOGCHECK every hour 1 0-23 * * * /usr/local/bin/logcheck.sh #Run the weather data get every 10 mins */10 * * * * /usr/local/bin/getwx #check if daemons have quit every 15 mins */15 * * * * /usr/local/bin/keepup # min hr day month dayofweek #Create web history at 1am each day 0 1 * * * /home/welsh/logs/webanal 0 1 * * * /home/logs/webanal # Do a time update once a day 00:29 29 0 * * * /usr/sbin/ntpdate cunixd.cc.columbia.edu NOTE: Most of these are bogus or commented out!!!. But use the comments and the time/day values as examples.... -- +----------------------------------------------------------------------------+ + Bruce S. Marshall bmarsh@bmarsh.com Bellaire, MI 08/27/01 11:30 + +----------------------------------------------------------------------------+ "There are only four words in the English language which end in "-dous": tremendous, horrendous, stupendous, and hazardous."
is the path needed. I need to send a signal. I want to run "killall -TERM proxyper" as the command. Will this work as it is? Thanks Ray Booysen ----- Original Message ----- From: "Bruce Marshall" <bmarsh@bmarsh.com> To: "suse users" <suse-linux-e@suse.com> Sent: Monday, August 27, 2001 5:34 PM Subject: Re: [SLE] CRON
PATH=/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6 /bin:/opt/bin:/opt/teTeX/bin:/opt/kde/bin:
+--------------------------------------------------------------------------- -+
+ Bruce S. Marshall bmarsh@bmarsh.com Bellaire, MI 08/27/01 11:30 +
+--------------------------------------------------------------------------- -+
On Monday 27 August 2001 05:21 pm, Ray Booysen wrote:
Dunno... You'd have to try it. I suspect the path is needed. +----------------------------------------------------------------------------+ + Bruce S. Marshall bmarsh@bmarsh.com Bellaire, MI 08/27/01 17:55 + +----------------------------------------------------------------------------+ "In a fight between you and the world, back the world."
On 27-Aug-01 Bruce Marshall wrote:
I'd reccomend always putting in the full path; that way you're safe. Cron sets up some environment variables for the commands it runs according to the user who owns the crontab file. For instance, it picks up $HOME from the user's entry in /etc/passwd (see man 5 crontab). So you could certainly have a crontab line like * * * * * $HOME/bin/myprog But $PATH is very much a "dynamic" variable for a user, and there's no reliable way cron could look for a user's particular current $PATH. If you want to make sure that cron uses a particular $PATH you can set this in the crontab file, with a line like PATH="/the/path:/you/want:/to/use" (nothing else: this sort of crontab line is not time-linked and so is global) in which case you can omit full paths from the cron commands provided they're covered by the crotab $PATH. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 28-Aug-01 Time: 10:48:41 ------------------------------ XFMail ------------------------------
participants (5)
-
Bruce Marshall
-
Cliff Sarginson
-
dog@intop.net
-
Ray Booysen
-
Ted.Harding@nessie.mcc.ac.uk