Cron expression generator
How to add it to your server
- Run
crontab -e(as the user the job should run as). - Add one line: the five fields, then the command. Use full paths, because cron has a very short PATH:
*/15 9-17 * * 1-5 /usr/bin/python3 /home/me/job.py >> /home/me/job.log 2>&1 - Save and close. Check it with
crontab -l. Cron uses the server's time zone: see it withtimedatectl.
More, including systemd timers: run scheduled tasks.
Cron syntax cheat sheet
| Write | Means | Example |
|---|---|---|
* | every value | * * * * * every minute |
a,b | a list | 0 8,20 * * * 08:00 and 20:00 |
a-b | a range | 0 9 * * 1-5 weekdays at 09:00 |
*/n | every n-th value | */10 * * * * every 10 minutes |
a-b/n | every n-th value in a range | 0 8-18/2 * * * every 2 hours from 08:00 to 18:00 |
@hourly @daily @weekly @monthly @yearly | shortcuts | @daily = 0 0 * * * |
@reboot | once, when the server starts | @reboot /home/me/start.sh |
Cron questions
What if I set both day of month and day of week?
Then the job runs when either matches, not both. 0 0 13 * 5 runs on every 13th and on every Friday. This page follows that rule, like the cron on Debian, Ubuntu and most Linux servers.
Why does my cron job not run?
The usual causes: a command that is not found because cron's PATH is short (use full paths like /usr/bin/python3), a script that is not executable, a % in the command (cron treats it as a new line, so write \%), or a time zone you did not expect. Send the output to a log file with >> file.log 2>&1 to see errors.
Can cron run a job every 30 seconds?
No, a minute is the smallest step. Use a systemd timer instead, or a loop in your script.
Is anything sent to your server?
No. The page works it all out in your browser.
More free tools: all tools, SSH key generator, DNS lookup, open port checker.