Python schedule a job at specific time

Is there any way to have a script with python that schedule a a job on a given datetime? For instance schedule a tweet at 01-09-2017 09:30:00.

So far I have seen the schedule and apscheduler libraries but I haven't find that allows me to schedule at a given time only for once.

Thanks!

Upvotes: 1

Views: 246

Answers (1)

stovfl
stovfl

Reputation: 15513

Question: schedule a tweet at 01-09-2017 09:30:00.

Simple Solution, for example:

if __name__ == __main__:
    starttime = datetime.datetime(2017, 9, 1, hour=9, minute=30, second=0)
    while True:
        if datetime.today() > starttime:
            break
        time.sleep(60)

    main()

Upvotes: 1

Related Questions