Skip to content

Instantly share code, notes, and snippets.

@nitish6174
Created February 22, 2021 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitish6174/94584b22e7b247a74175bbf7ef8c5b6b to your computer and use it in GitHub Desktop.
Save nitish6174/94584b22e7b247a74175bbf7ef8c5b6b to your computer and use it in GitHub Desktop.
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