简体   繁体   中英

Execute a Python script with Crontab

I'm trying to execute a python script using crontab. I want to run this script every 2 hours. I use:

export EDITOR=nano
crontab -e

then:

0 */2 * * * cd /Users/myname/Desktop/CoronaFR/ && /opt/anaconda3/bin/python3 CoronaFR.py

But it doesn't work. Any idea? Maybe a path problem?

Thanks in advance!

Try

0 */2 * * * /opt/anaconda3/bin/python3 /full/path/to_the_script/CoronaFR.py

You can remove cd command and directly call the script by this command:

0 */2 * * * /opt/anaconda3/bin/python3 /Users/myname/Desktop/CoronaFR/CoronaFR.py

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