Crontab generator
What is a Crontab Generator?
Writing a crontab line by hand means remembering field order and syntax, and a mistake can mean a backup that never runs or a job that fires every minute. This generator lets you choose the schedule with options, then produces the matching cron expression and a plain-English description to confirm it.
How to use it
- Choose when the job should run: every N minutes, specific hours, certain weekdays or days of the month.
- Read the generated expression and its description.
- Add your command and paste the line into
crontab -e.
A complete crontab line
30 3 * * 0 /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
This runs the backup script every Sunday at 03:30 and appends both output and errors to a log file.
Best practices
- Use absolute paths. Cron runs with a minimal
PATH, so commands that work in your shell may not be found. - Redirect output. Otherwise cron tries to email it, and errors disappear silently on systems without mail.
- Set environment variables such as
SHELL,PATHorMAILTOat the top of the crontab. - Escape percent signs. In crontab, an unescaped
%becomes a newline, sodate +%Fmust be written asdate +\%F. - Avoid overlaps. Wrap long jobs with
flockso a slow run does not start a second copy. - Spread load. Avoid scheduling everything at minute 0; pick odd minutes like 7 or 23.
Useful commands
crontab -llists your jobs.crontab -eedits them.grep CRON /var/log/syslogshows whether jobs ran on Debian and Ubuntu.
Frequently Asked Questions
How do I add a cron job?
Run crontab -e, paste the generated line followed by your command, save and exit. The job is active immediately.
Why does my cron job not run?
Common causes are relative paths, a missing PATH, unescaped percent signs and permission problems. Redirect output to a log file to see errors.
How do I run a job every 5 minutes?
Use */5 * * * * followed by the command.
Where are cron logs?
On Debian and Ubuntu, in /var/log/syslog. On Red Hat-based systems, in /var/log/cron. With systemd, use journalctl -u cron.