LinuxCommandLibrary

cron

TLDR

Edit crontab

$ crontab -e
copy
List cron jobs
$ crontab -l
copy
Remove crontab
$ crontab -r
copy
Edit another user's crontab
$ sudo crontab -u [user] -e
copy
Install crontab from file
$ crontab [crontab.txt]
copy

SYNOPSIS

crontab [options] [file]
cron [options]

DESCRIPTION

cron is the daemon that executes scheduled commands. crontab manages per-user cron tables. Jobs run at specified times, dates, or intervals for automated system maintenance.

CRONTAB OPTIONS

-e

Edit crontab
-l
List crontab
-r
Remove crontab
-u user
Operate on user's crontab (requires root)
-i
Prompt before removal

CRON DAEMON OPTIONS

-n

Run in foreground
-m command
Mail command (or "off" to disable)
-s
Log to syslog
-p
Accept any user crontab

CRONTAB SYNTAX

$ * * * * * command
│ │ │ │ │
│ │ │ │ └─ Day of week (0-7, Sun=0 or 7)
│ │ │ └─── Month (1-12)
│ │ └───── Day of month (1-31)
│ └─────── Hour (0-23)
└───────── Minute (0-59)
copy

SPECIAL STRINGS

@reboot: Run at startup
@hourly: 0 * * * *
@daily: 0 0 * * *
@weekly: 0 0 * * 0
@monthly: 0 0 1 * *
@yearly: 0 0 1 1 *

FILES

/etc/crontab: System crontab
/etc/cron.d/: System cron jobs
/var/spool/cron/: User crontabs

CAVEATS

Jobs run with limited environment. Set PATH explicitly in crontab. Output mailed to user unless redirected. Use MAILTO="" to disable mail.

SEE ALSO

crontab(5), at(1), systemd.timer(5)

Copied to clipboard