Running the script on a regular basis

A final step in the script is to schedule the script to run at a time interval. This can be daily, weekly, hourly, or at a specific time. This can be done using the cron job on Linux systems. cron is used to schedule a repeated event, such as cleaning up directories, backing up databases, rotating logs, or anything else you can think of.

To view the current jobs scheduled, use the following command:

crontab -l

To edit crontab, use the -e switch. If this is the first time you are running cron, you will be prompted to use your favorite editor (nano or vi).

A typical crontab consists of five stars, each one representing a time entry:

Field

Values

Minutes

0-59

Hours

0-23

Day of the month ...

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.