To schedule a cron job at every five minutes, use the following syntax:
*/5 * * * * user-name /path/to/command
# | | | | |
# | | | | .---- Every day of the week
# | | | .------- Every month
# | | .---------- Every day
# | .------------- Every hour (* = any value)
# .----------------- Every five minutes (/ = step values)
To schedule a cron job to run every five minutes, you would use the following cron expression:
*/5 * * * *
*/5
— Every five minutes*
— Every hour*
— Every day of the month*
— Every month*
— Every day of the weekOpen the terminal.
Type crontab -e
to edit the cron jobs for the current user.
Add your cron job using the above expression followed by the command you want to run. For example, to run a script located at /path/to/your/script.sh
, you would write:
*/5 * * * * /path/to/your/script.sh
Save the file and exit the editor.
If you wanted to run a Python script every five minutes, it might look like this:
*/5 * * * * /usr/bin/python3 /path/to/your/script.py
chmod +x /path/to/your/script.sh
)./var/log/syslog
(on some systems) to see if it is executing as expected.