Creating a New Job
We may use the following command to create a new cron job after we’ve accessed cron:
cron.new(command="cron_command")
For example, to create a cron job to run a python file temp.py every minute, we can do so by typing the below code:
from crontab import CronTab cron = CronTab(user='root') job = cron.new(command='python temp.py') job.minute.every(1) cron.write()
Create Multiple jobs using python-crontab
Cron is a Unix-like operating system software utility that allows us to schedule tasks. Cron’s tasks are specified in a Crontab, which is a text file that contains the instructions to run. The Crontab module in Python allows us to handle scheduled operations using Cron. It has functionalities that allow us to access Cron, create jobs, establish limitations, and remove jobs, among other things. In this article, we will perform Multiple jobs using Python-Crontab.
Let’s get started.