How to run a virtual python Environment on the linux crontab?

Asked

Viewed 171 times

0

created a virtual Environment:

python -m venv test
pip install -r requirement.txt

And I created a scrip C:\fnord\Documents\Scripts_python\test\Scripts\test.py

So, how should I proceed to create scheduling, for example:

30 08 10 06 * python C:\fnord\Documents\Scripts_python\test\Scripts\test.py

1 answer

2


Just use the full path to python installed in virtualenv.

30 08 10 06 * /home/venv/bin/python3 /<caminho_do_script>/Scripts/test.py

You can also create a . sh script that enables virtual Environment and then call your python script. This helps when you have several actions to perform.

  • (opa Rodrigo - I changed a little the phrase there just to be very clear - but thanks for the quick and correct answer)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.