Python script to do something at the same time every day [duplicate]

I spent quite a bit of time also looking to launch a simple Python program at 01:00. For some reason, I couldn’t get cron to launch it and APScheduler seemed rather complex for something that should be simple. Schedule ( seemed about right.

You will have to install their Python library:

pip install schedule

This is modified from their sample program:

import schedule
import time

def job(t):
    print "I'm working...", t

schedule.every()"01:00").do(job,'It is 01:00')

while True:
    time.sleep(60) # wait one minute

You will need to put your own function in place of job and run it with nohup, e.g.:

nohup python2.7 &

Don’t forget to start it again if you reboot.

Leave a Comment