Back to the command reference

crontab

SystemFundamentals In real Linux

Schedule recurring jobs

Name: crontab = cron table; cron comes from Greek chronos (time)

This command needs a real Linux system; you can practise it in real Linux mode.

Full man page

Description

crontab edits and lists your scheduled jobs, which the cron daemon runs on time. Each line is a job: five fields for minute, hour, day of month, month and weekday, then the command; 0 2 * * * means 02:00 daily.

cron runs jobs with a minimal environment (a short PATH), so use full paths and redirect output to a log.

Syntax

crontab [OPTION]...

Common options

-eEdit your jobs
-lList your jobs
-rRemove all your jobs
-u USERWork on another user’s table (needs root)
分 时 日 月 周Schedule fields, e.g. 0 2 * * * is 02:00 daily

Examples

  • $ crontab -e

    Open an editor to add jobs

    Explain
  • $ 0 2 * * * /home/user/backup.sh

    (in the crontab) Back up every day at 02:00

    Explain
  • $ crontab -l

    Show existing jobs

    Explain

Related