Akkfic
Akkfic

Reputation: 57

Multiple jobs using python-crontab

I am using python-crontab to build a Desktop notification system. However, I can not figure out how to schedule multiple scripts using python-crontab.

Here is what I have to schedule one script:

my_user_cron  = CronTab(user=True)
job=my_user_cron.new(command='usr/bin/python3 /Users/Desktop/script.py', comment='script')
job.setall(* * * * *)
my_user_cron.write()

If anyone knows how to schedule multiple scripts using this library, please let me know. If you need more information or have any questions, feel free to ask.

Upvotes: 0

Views: 961

Answers (1)

Subasri sridhar
Subasri sridhar

Reputation: 831

See if this helps :


cron = CronTab(user='username')

job1 = cron.new(command='python example1.py')

job1.hour.every(2)

job2 = cron.new(command='python example1.py')
job2.every(2).hours()

for item in cron:
    print item

cron.write()

Upvotes: 2

Related Questions