Skip to content
BENIBIX Learn

Cron

Infrastructure⌨️ Linux & the Command LineProcesses and Services

Also known as Cron Job, crontab, Cron Daemon, Scheduled Job

A tool that runs commands on a plan, like each night at 3.

Think of it like

Think of it like an alarm clock that does a chore when it rings.

Example

Emma wants a backup every night. She adds one line to her crontab, and the backup runs at 3 a.m. each day.

Why it matters

Backups and clean-ups run on their own. No one has to remember them.

Definition

Cron is a daemon that runs commands for you on a set schedule. Each job is one line in a table called a crontab. The line has a time pattern, then the command to run. Cron checks the table every minute and starts any job whose time has come. You edit your own table with crontab -e.

Example code

console
$ crontab -l
0 3 * * * /home/emma/backup.sh
One job: run the backup script at 3:00 every day.
The five fields on the left say when. The command on the right says what.

Common mistake

Assuming a cron job sees the same settings as your shell. It runs with a bare setup, so use full paths.

Key takeaways

  1. 1
    One line per job. A time pattern and a command.
  2. 2
    Checks each minute. Runs what is due.
  3. 3
    Use full paths. Cron has a bare setup.

Learn it properly