I need to run a python script from a virtual environment. This will be run from s shell script which in turn will be called from Crontab scheduler.
I am not able to activate the environment when the shell script is called from Crontab
I'm not sure about this, but try and put this in a shell script:
cd ~/<path>
source <env>/bin/activate
python <script>.py
Activate your virtualenv to identify the interpreter path:
workon myVenv1
which python
/home/www-user/virtualenvs/myVenv1/bin/python
So the cronjob should look like this:
* * * * * /home/www-user/virtualenvs/myVenv1/bin/python <full_path_to_script>
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.