When to use crontab
Use crontab to inspect or edit recurring tasks for the current account. Jobs normally run with a limited environment and no interactive terminal, so use absolute paths and plan how output and failures will be recorded.
Syntax
crontab [PARAMETERS]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
View schedule
crontab -lThe current account's installed schedule is displayed if one exists.
Save a copy of the schedule
crontab -l > ./crontab.backupThe schedule is redirected to a backup file. Check command success before relying on that backup; an existing output file is replaced.
Open schedule editor
crontab -eThe schedule opens in the configured editor; saving valid changes installs the updated table.
Notes and limitations
- The entry contains minutes, hours, day of month, month, day of week and command. For example: 0 3 * * * /usr/local/bin/backup.sh.
- The cron environment is limited: use absolute paths and customize the output. crontab -r deletes the entire schedule.
Common questions and troubleshooting
Why does a command work over SSH but fail in cron?
The working directory, environment, command path and available credentials can differ. Make those dependencies explicit and inspect job output.
Which timezone does a cron schedule use?
It depends on the system and cron implementation. Confirm the server timezone and any supported per-table timezone configuration before scheduling important work.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man crontab.