Cron

From OCF Help

Jump to: navigation, search

cron is a service provided on Unix systems that is useful for scheduling repetitive tasks that should be performed on a regular basis.

Because of possible system load issues, as well as consistency, we allow cron jobs at only one server, accessible as cronhost.ocf.berkeley.edu. To use this service, do the following:

  1. SSH to cronhost.ocf.berkeley.edu
  2. run:
    crontab -e
  3. Edit the file in the following format:
    0 0 * * * path/to/program
    • The fields are, in the following order, with valid values in parenthesis: minute (0-59), hour (0-23), day of the month (1-31), month of the year (1-12) day of the week (0-6 with 0 as Sunday). You can use "*" as wildcard (i.e. every minute/hour/day/month), and you can specify more than one value either by listing it as comma-separated-list or listing the range:
    • Example: Following cronjob will run run every hour from midnight to 4 a.m. (for total of 5 hours) on Mondays and Thursdays:
      0 0-4 * * 1,4 path/to/program
  4. Save and exit. To confirm that your cronjob has been scheduled, run:
    crontab -l
    If your cronjob produces any output to STDIN (i.e. if it has a screen output) that output will be emailed to you when the job is run. If this is not a desired behavior, you might wish to redirect output.

Hints

  • By default (i.e. if your EDITOR variable is not set) crontab will use vi to edit the file. If you are not familiar with vi, you can try a more user-friendly editor by running instead:
    bash -c "EDITOR=/opt/local/bin/pico crontab -e"
    in step 2.

See Also

  • On cronhost,ocf.berkeley.edu run:
    man cron
    to learn more about the cron daemon, and run
    man 5 crontab
    to learn more about the list you need to edit.
Personal tools