简体   繁体   中英

configure crontab job use Anaconda python packages

I have installed Anaconda on my server.
However, when I setup a cron job to schedule a script, it uses the default python installed on the system.

How do I use the Anaconda version?

This is my current cron job:

01 00 * * * python /home/ubuntu/data_scripts/test.py

If you know the installed path , you can define your python path to your crontab.

For example, if the installed path is /usr/bin/python or /usr/bin/python3 your crontab would look like this:

01 00 * * * /usr/bin/python /home/ubuntu/data_scripts/test.py  
01 00 * * * /usr/bin/python3 /home/ubuntu/data_scripts/test.py 

Note: As @ asmeurer mentioned, if you are using ubuntu your installed path probably will look more like this /home/ubuntu/anaconda/bin/python

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