×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

INSTALLATION

Crontab Intro by Faroon
Posted: 29 Sep 03

This is the built-in automation tool for users of OpenBSD to set up task scheduling. Each user can have a separate crontab that holds several cronjobs to be executed periodically by a cron daemon. Synopsis:

$ crontab [-u (for user)] [-e (edit) | -l (list) | -r (remove)]

Synopsis of a command line in the contab (a cronjob):

    Minute û Hour û Day of month û Month û Day of week /path/to/command /path/to/file

    Minute:    0 û 59
    Hour:        0 û 23
    Day of month:    1 û 31
    Month:        1 û 12
    Day of week:    0 û 6, 0 = Sunday
    
Note:    * = any value

User capacityÆs cronjobs:

    # Refresh database tables everyday at 2:15am
15 2 * * *    /usr/bin/perl    /path/to/scripts/database_refresh.pl

# Backup table mytable and every Saturday 9:30am
30 9 * * 6    /usr/bin/perl    /path/to/scripts/backup.pl

To edit a cronjob, do:
$crontab -l > temp.txt  --> write current cronjob to file
$pico temp.txt (or use nano, of vi) --> make changes
$crontab temp.txt  --> install back the job

Alternate way:
$export EDITOR=/path/to/pico (or nano, vi is default)
$crontab -e  -->edit and save new jobs

Important: Cron has a different set of environmental variable settings from that of the user's. For example, the user's $PATH setting might have /sbin:/usr/sbin:/usr/local/sbin, but cron's $PATH might not. Sometimes extra environmental settings are required for a job to run inside cron. To make these setting, simply edit the cron, and add the neccessary settings on top of file (ex. add PATH=$PATH:/sbin:/usr/sbin)

Note: should a cronjob produce any error message, this message will be mailed to the owner of that cronjob. Simply type æmailÆ to open the email folder and view the cron daemon mail.

Back to Linux (server) FAQ Index
Back to Linux (server) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close