Crontab

Usage

A crontab is a file that holds the instructions for the cron daemon.

Each cronjob within the crontab will run a specific command at a specific time based on the crontab configuration.

  • Commands:
    • crontab <filename>: command to run cron-jobs within a separate file as an argument
    • crontab -e: edit current user’s crontab
    • crontab -l: list current user’s crontab
    • crontab -r: delete user’s crontab
    • crontab -i: prompt before deleting user’s crontab

Open crontab

View the crontab file with the follwing command:

crontab -e

Output:

crontab-e output

The default user crontab seen from the previous command will look similar to the above screenshot.

Bonus

The global crontab config file can be viewed with the following command:

sudo vim /etc/crontab

In addition to the five time parameters, and command to execute, the global crontab config file requires the user that will execute the command

* * * * * user-name command-to-run

sudo vim /etc/crontab output

The file was opened with vim and can be closed with :q.