Reputation: 55
I have a script which I desire to run once a day, now i can achieve this
with simpletime.sleep(60*60*24)
, then usingnohup python ...
Now i am not sure, what constraints time.sleep function would have on CPU ?
Other approach would using cron job ?
Upvotes: 0
Views: 80
Reputation: 2500
"sleep" has no impact on the cpu.
But cron job is a better approach for many reasons :
Upvotes: 1
Reputation: 451
Cron is a much better solution as it becomes responsible for starting and stopping the script. Your other choice is to have your script working 24 hours a day plus some mechanism to re-start it if it locks up and start at reboot, etc.
Cron is way simpler and more dependable.
Upvotes: 0