Created
February 22, 2021 16:49
-
-
Save nitish6174/94584b22e7b247a74175bbf7ef8c5b6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from crontab import CronTab | |
from datetime import datetime | |
cron = CronTab() | |
cmds = { | |
'python ~/code/reminder.py': '0/30 9-18 * * *', | |
'~/code/backup.sh': '0/30 9-18 * * *', | |
} | |
for cmd, cron_str in cmds.items(): | |
cron_job = cron.new(command=cmd) | |
cron_job.setall(cron_str) | |
for result in cron.run_scheduler(): | |
current_time = datetime.now().strftime("%H:%M:%S") | |
print("cron run at", current_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment