How to Schedule Automatic Tasks with cron on Linux

Syntax, practical examples and the most common mistake (relative paths).

Advanced 1 min read Published on 2026 By Equipo SolucionaPC

cron runs commands automatically at the times you define, without you having to remember to do it manually.

crontab -e

Each line follows this format:

# minute hour day month weekday command
0 2 * * * /path/to/script.sh
ExampleMeaning
0 2 * * *Every day at 2:00 AM
*/15 * * * *Every 15 minutes
0 9 * * 1Every Monday at 9:00 AM
0 0 1 * *On the 1st of every month

Tip: always use the script's full path (not a relative one) — cron doesn't run tasks from your home folder, so a relative path that works fine manually can fail silently inside cron.

Viewing your scheduled tasks

crontab -l

Note: if a cron task doesn't seem to be running, check the system log (grep CRON /var/log/syslog) to confirm whether it was actually attempted and what error it gave, if any.

Frequently asked questions

Why does my script work manually but not from cron?

The most common cause is using a relative path instead of the full path — cron doesn't run tasks from your home folder, so relative paths may not find the files they need.

How do I check whether a cron task ran?

Check the system log with 'grep CRON /var/log/syslog' (or journalctl on more modern systems), which shows whether the task was attempted and any associated error.

Share: