$linuxjunkies
>

crontab(1)

Install, list, edit, or remove cron jobs for the current user.

UbuntuDebianFedoraArch

Synopsis

crontab [-u user] [-l | -e | -r | -i]

Description

Crontab installs a table of cron jobs to be run by the cron daemon at specified times. Each user has their own crontab file, stored in /var/spool/cron/crontabs/. The crontab file contains six fields per line: minute, hour, day of month, month, day of week, and command to execute.

Fields are space-separated integers or special characters (* for any, - for range, , for list, / for step). Use -e to edit, -l to list, -r to remove, and -i to prompt before removal.

Common options

FlagWhat it does
-eEdit the current user's crontab using the editor specified by VISUAL or EDITOR
-lList the current user's crontab entries
-rRemove the current user's crontab file
-iPrompt the user for confirmation before removing the crontab (used with -r)
-u userOperate on the specified user's crontab (requires root privileges)
-sAppend the current SELinux security context to crontab entries

Examples

Open the current user's crontab in the default editor for editing

crontab -e

Display all scheduled cron jobs for the current user

crontab -l

Example crontab line: run backup.sh every day at 2:00 AM

0 2 * * * /usr/local/bin/backup.sh

Example crontab line: run check_status.sh every 15 minutes

*/15 * * * * /usr/bin/check_status.sh

List the crontab for user 'alice' (requires root)

crontab -u alice -l

Remove the current user's entire crontab file

crontab -r

Remove crontab with a confirmation prompt

crontab -i -r

Example crontab line: run script monthly on the 1st at midnight, logging output

0 0 1 * * /opt/script.sh > /var/log/script.log 2>&1

Related commands