One of the nicest feelings in Linux is making the machine do something useful while you are not watching.
Back up a folder.
Refresh a report.
Run a script every morning.
Clean up a temporary directory once a week.
That is the emotional promise of cron.
But the first time people use it, cron often feels more mysterious than helpful. A job looks syntactically correct, the command works perfectly in the terminal, and then nothing happens at the scheduled time. That can make cron seem unreliable when the truth is usually much simpler:
cron is strict, not mystical.
- What cron and crontab each actually do
- How the five scheduling fields really work
- Why commands fail in cron even when they work interactively
- The examples I think beginners should start with
- When cron is the wrong tool and anacron matters more
Cron is the scheduler, and crontab is how you feed it jobs
The current Linux manual pages make the division very clear.
cron(8) describes the daemon itself. It is the background service that reads scheduling data and executes jobs at the right times. crontab(1) describes the utility used to install, edit, list, or remove a user’s crontab.
That separation is useful because it gives the whole system a cleaner shape:
cronis the engine;crontabis the interface you use to tell the engine what to run.
And for most beginners, the normal entry point is:
crontab -e
The manual page says -e edits a copy of the invoking user’s crontab and installs it when you finish. That is an important detail. You are not supposed to poke random files in /var/spool directly. The command exists so that cron job management stays structured.
The basic crontab syntax is simple, but you have to respect its precision
The crontab(5) manual page says a crontab entry is effectively “run this command at this time on this date,” and it breaks the scheduling part into five fields:
- minute
[0-59] - hour
[0-23] - day of month
[1-31] - month
[1-12] - day of week
[0-7], with0or7meaning Sunday
Then comes the command.
That is the whole skeleton.
A classic daily example looks like this:
0 2 * * * /home/alex/scripts/backup.sh
That means:
- minute
0 - hour
2 - every day of the month
- every month
- every day of the week
So it runs at 02:00 every day.
The manual page also documents lists, ranges, and step values, which is where cron starts feeling more expressive:
1,15,30means a list;1-5means a range;*/10means every 10 units in that field.
That gives you patterns like:
*/15 * * * * /home/alex/scripts/check-status.sh
which means every 15 minutes.
The important thing is not memorizing every variation immediately. It is understanding that each field has its own meaning and its own valid range. Cron is happy to be repetitive. It is not happy to infer what you meant.
The biggest beginner problem is usually not the schedule; it is the environment
This is the part I wish more guides emphasized early.
The crontab(5) man page explains that cron sets SHELL=/bin/sh, HOME, and LOGNAME automatically from the passwd entry for the user running the job. It also notes that comments are not allowed on the same line as commands or environment settings.
That means a cron job does not run inside the same rich interactive environment you probably used when you tested the command manually.
This is why jobs fail so often:
- the script depends on a PATH entry that cron does not have;
- the command assumes Bash features while cron runs it under
/bin/sh; - a relative path works in your shell but fails in cron;
- output or errors vanish because nothing was redirected.
That is why my safest beginner rule is brutally simple:
- use absolute paths for scripts, binaries, and files;
- test the exact command manually first;
- if the script needs Bash, call Bash explicitly;
- log output on purpose.
Instead of this:
*/30 * * * * backup.sh
I would much rather see:
*/30 * * * * /bin/bash /home/alex/scripts/backup.sh >> /home/alex/logs/backup.log 2>&1
That line is less elegant, but much more honest.
The first cron jobs I trust are the boring ones
I think beginners learn cron faster when they stop trying to schedule something “important” first.
The first jobs should be low-stakes and very visible.
For example, append a timestamp to a file every minute:
* * * * * /bin/date >> /home/alex/cron-test.log 2>&1
This teaches several useful things at once:
- the schedule is easy to verify;
- the command is simple;
- the output goes somewhere visible;
- if it fails, the debugging surface is small.
Once that works, moving to something like a cleanup task feels much safer:
30 3 * * 0 /usr/bin/find /home/alex/tmp -type f -mtime +7 -delete >> /home/alex/logs/tmp-clean.log 2>&1
That kind of progression matters. Cron becomes trustworthy when you build confidence in layers, not when you drop one complicated production command into a crontab and hope.
Some crontab details are easy to miss but worth respecting
The crontab(5) page includes a few details that beginners usually discover only after confusion.
One important one is the way day-of-month and day-of-week interact. The manual says that if both are restricted, the job runs when either field matches. That catches people off guard because many assume both conditions must be true simultaneously.
Another useful detail is the special syntax for nicknames, which many cron implementations support:
@reboot@yearly@monthly@weekly@daily@hourly
These are easier to read than raw numeric schedules when they fit your intent. For example:
@daily /bin/bash /home/alex/scripts/daily-report.sh >> /home/alex/logs/daily-report.log 2>&1
That is often clearer than writing the equivalent numeric line just to prove you can.
Cron is not always the best fit on machines that are not always on
This is where anacron(8) becomes worth mentioning.
The anacron manual page says that unlike cron, it does not assume the machine is running continuously. It is designed for periodic jobs with frequencies expressed in days and is particularly useful on machines that are not up 24/7.
I think this is an important realism check.
If you schedule a cron job for 03:00 on a laptop that is usually asleep or powered off at 03:00, the problem is not that cron is broken. The job simply missed its moment because cron is time-based, not intention-based.
That means:
- use cron for precise recurring times when the system is expected to be running;
- think about anacron or other schedulers when the machine is not always awake and connected.
That distinction saves a lot of unnecessary blame.
My safest cron workflow is deliberately unglamorous
When I schedule something with cron, I try to keep the process very plain:
- write and test the command manually first;
- convert all important paths to absolute paths;
- decide whether the job needs Bash explicitly;
- redirect stdout and stderr to a log file while testing;
- install the job with
crontab -e; - confirm it actually ran by checking the result, not just admiring the line.
That workflow is boring, and I think boring is exactly what scheduled automation should feel like.
The moment a cron job becomes “clever,” it usually becomes harder to trust.
Verification note: Commands, terminology, and support details in this guide were cross-checked against Ubuntu’s official crontab manual.
For broader context, continue with Trying Linux Without Installing: A Guide to Live USBs and How I Run Alpine-Based LXC Containers for Ultra-Lightweight Homelab Services.
Conclusion
Cron jobs become much easier once you stop thinking of them as tiny background spells and start treating them as strict scheduled commands. cron is the daemon that runs the jobs, crontab is how you manage your entries, and the five scheduling fields are simple once you respect their exact meanings. The real beginner challenge is usually not the timing syntax at all. It is remembering that cron runs in a smaller environment than your interactive shell and therefore rewards absolute paths, explicit shells, and intentional logging.
That is the version of cron I trust most. Not magical. Not fragile. Just exact. And once you learn to work with that exactness instead of fighting it, scheduled automation starts feeling calm rather than mysterious.
FAQ
Why does a command work in my terminal but fail as a cron job?
Usually because the cron environment is smaller than your interactive shell environment. PATH entries, shell features, working directories, and environment variables may differ, which is why absolute paths and explicit shells make cron jobs much more reliable.
When should I use anacron instead of cron?
Use anacron when the machine is not always running and the task only needs to happen daily, weekly, or monthly rather than at one exact minute. Cron assumes the system is up at the scheduled time, while anacron is designed for systems that may be powered off or asleep.



