简体   繁体   中英

Run Python Script - Cron

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM