I have a python script I want to fire off every night at midnight. I'm using cron scheduler right now to do so, however, I can't figure out why it's not working. For now, I've been using close times (within the next minute or so) to test the cronjob, but I will ultimately want it to work for midnight.
Here is what I put in my crontab file (to run for 2:43pm), hosted on my ubuntu machine:
43 14 * * * root /home/grantmcgovern/Developer/Projects/StudyBug/Main.py
I even put the:
#!user/bin/python
on top of all the .py files.
I also did:
chmod +x "scriptname".py
For each of the .py files and still no luck. Am I missing something blatantly obvious? I should note, this is my first time playing with cron tasks.
解决方案
From your current crontab file, you're basically running root /home/grantmcgovern/Developer/Projects/StudyBug/Main.py every time.
If you want to run it as root, use sudo crontab -e and put 43 14 * * * /usr/bin/python /home/grantmcgovern/Developer/Projects/StudyBug/Main.py instead.