crontab
Processes and system
Usage
crontab -e | crontab -lEdits the per-user schedule table; cron runs with almost no PATH and never reads your login profile, so write absolute paths, and `crontab -r` erases the whole table without asking.
Common flags
| Flag | Meaning |
|---|---|
| -e | Edit your table in $EDITOR; it is installed when you save. |
| -l | Print your table. Redirect it somewhere to keep a backup. |
| -r | Delete the whole table at once, with no confirmation. |
| -u <user> | Work on another user's table (root only). |
| m h dom mon dow | The five time fields, then the command. * means every. |
| @reboot / @daily | Shorthand instead of the five fields. |
Examples
crontab -l > ~/cron.bakBack up the table before touching it.
crontab -eThen add: 0 3 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
crontab -l | grep -v backup.sh | crontab -Remove one line without opening an editor.
What is running and what is eating the machine. Identifying it comes before killing it.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does crontab do?
Edits the per-user schedule table; cron runs with almost no PATH and never reads your login profile, so write absolute paths, and `crontab -r` erases the whole table without asking.
Q. How do I type it?
crontab -e | crontab -l — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
6 are listed here; the full set is in man crontab. This command sits under Processes and system.
Related commands
man page: man crontab