Run Python files with Cron on Linux - Job Scheduling Guide
Learn to use cron to schedule jobs to run automatically at specific times and days on Linux systems.
6 min readApr 29, 2023
A crontab file consists of lines — called cron jobs — which specify when to run what command. And so they consist of 2 parts:
- Scheduled times — This part consists of 5 parts that together determine when to run the cron job.
- Command to run — This is just a regular Linux command that will be run at the scheduled times.
How to set the scheduled times for cron jobs in a crontab file?
The scheduled time of a cron job is specified with 5 parts separated by spaces, for example: 0 7 25 12 *
.
The parts have their own roles and specify:
- what minute to run (0–59)
- what hour to run (0–23)
- what day of the month to run (1–31)
- what month to run (1–12)
- what day of the week to run (0–6 where 0 is Sunday and 6 is Saturday)
The cron expression 0 7 25 12 *
stands for 7:00 on the 25th of December.