b r a y d e n . o r g / Random

/ WebHome / CategoryWebsite / CronTutorial

This Web


WebHome  
Topic List  
Web Statistics 

All Webs


Books
Main
Random
Software
TWiki  

brayden.org


Home
Monthly Digest
Today's Links
Resumé
Reading List
Books RSS
Random RSS
Software RSS

Other


Dale's Blog

currently-reading
TextDrive

Cron Tutorial

From the powweb tutorials section.

How Cron Works

Cron will allow for you to run a command at a specific time automatically. Whether you need it to run daily or weekly, you'll be able to accomplish this once the task is set up through Cron. Cron in essence is similar to a task scheduler, like the one built into the Windows Operating System.

Setup

To set up Cron properly, you will need to do the following:

  1. Create a file called crontab
  2. Place the commands in the file using the format below:
  3. Upload the file to the etc directory
    • Note: This file must be uploaded in ASCII mode. If this is the first time for uploading this file, you'll need to wait until midnight PST. Subsequent changes will be effective after you update the file.

Proper Format

Only one command can be on a line, and follow this format:

minute hour day month weekday command

To specify multiple values for a field, separate the values with commas. For example

15,45 0,6,12,18 * * *

will run a command at 15- and 45- minutes after the hour at 12AM, 6AM, 12PM, and 6PM.

command

The command is the /www/ui/user/your/script part of the cronjob.

Make sure the cronjob is being run from the base directory of the server, so you will need to specify the full path:

/www/ui/user/your/script  not  /your/script

Note: Make sure to change the path to reflect your directory. ui = username initial (the first letter)

Wildcard Usage:Asterisks (*) specify when commands are to be run in every instance of the value of the field. For instance, an asterisk in the Month field would mean that the command should be run every month.

Errors/Logging

Output from a script will not be sent anywhere, unless you specify a location for this information to go. This will enable you to see whether or not your command was successful. To enable this, add the following to the crontab, after your command:

>>/www/u/user/logs/script.log 2>>/www/u/user/logs/script.err

This will write all output to script.log, and send any error information to script.err.

Note: Make sure you change the path to reflect your directory.

For more information about cronjobs, please visit the following web site:

http://www.uwsg.iu.edu/usail/automation/cron.html

Contributed by ffejy

cron for twiki change notification

45 1 * * * (cd /www/u/user/pathtotwikibin; ./mailnotify -q)

This should run the mailnotify program at 1:45 every morning.

-- DaleBrayden - 11 Jul 2002

 
 
Current Rev: r1.3 - 25 Jun 2003 - 03:12 GMT - DaleBrayden, Revision History:Diffs | r1.3 | > | r1.2 | > | r1.1
© 2003-2011 by the contributing authors.