0

How can I run a python script once at exactly 12:00PM on Wednesday (Jan 21)?

I've added #!/usr/bin/env python to the top of my script and made the script executable with chmod +x

I know I want to do something like crontab -e 0 0 * * * /path/to/my/pythonscript.py but I'm not exactly sure how to get it to be a specific time...

Apollo
  • 8,874
  • 32
  • 104
  • 192
  • possible duplicate of [How to setup cron to run a file just once at a specific time in future?](http://stackoverflow.com/questions/5473780/how-to-setup-cron-to-run-a-file-just-once-at-a-specific-time-in-future) – Joel Hinz Jan 18 '15 at 20:38
  • @JoelHinz How would I get this to be March 30 at 1PM? 0 0 30 3 ? 2011 – Apollo Jan 18 '15 at 20:39
  • Possible duplicate of [Python script is not running under cron, despite working when run manually](https://stackoverflow.com/q/6363023/608639). – jww Nov 17 '19 at 18:40

1 Answers1

1

To run on 21 Jan at 12pm you will need the following line in your crontab file: 0 12 21 1 * /path/to/my/pythonscript

Edit the crontab file with crontab -e

The first number is minute, the second number is hour, the third one day of month, the fourth month, the fifth is day of week (in this case a * for any day of week), then the path.

The wikipedia entry on Cron is really helpful if you want to change the times.

Geotob
  • 2,847
  • 1
  • 16
  • 26