LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

cron

time-based job scheduler daemon

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. Together they provide time-based job scheduling for automated system maintenance, backups, log rotation, and recurring tasks.The cron daemon starts at boot and runs continuously, waking up every minute to check all crontab files for jobs that need execution. Each user can have their own crontab file, and the system has crontabs for system-wide maintenance. Jobs run in the background without user interaction, making cron essential for Unix/Linux system administration.

CONFIGURATION

/etc/crontab

System-wide crontab file with additional user field for running jobs as specific users.
/etc/cron.d/
Directory containing system crontab files in the same format as /etc/crontab.
/var/spool/cron/
Directory containing per-user crontab files managed via the crontab command.

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 *

INSTALL

sudo apt install cron
copy
sudo zypper install cron
copy
nix profile install nixpkgs#cron
copy

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)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid