crontab python 1

crontab python

from crontab import CronTab
cron = CronTab(user='root')
job = cron.new(command='echo hello_world')
job.minute.every(1)
cron.write()

Here is what the above code is Doing:
1. Importing the CronTab class from the crontab module
2. Creating a new CronTab object
3. Creating a new CronJob object
4. Setting the CronJob to run every minute
5. Writing the CronTab object to the crontab file

Similar Posts