I have a cronjob which needs to use python environment to run on schedule…
I tried first solution mentioned in in this tread, it is working when I click “Run Now” button in cron job set-up window but not working when i schedule it…
Also I am not sure where it logs the error., so I can look for solution…
my jobs looks like this…
it perfectly runs with “Run Now” button with all users(ex: root, webiste-user)
I followed the same steps before posting my question here…
I used full path of python environment.
I set domain owner to run this job.
not sure what’s happening…
is there any place are we logging error for cron jobs.??
sure, you can redirect output of that file temporary to log file or text file and that should tell you. I think you did not understand… the correct path should be
/usr/bin/python /path/to/your/script.py and not /home/user/myenv/bin/python…
try to run it like this:
I believe you have not read the title of this post… I want to run python script with specific virtual environment. not from default virtual environment…
I already have a corn job which are running without any problem when I give path like above… but when I use specific python virtual environment… its not working…
I have to use this virtual environment because all the required package installed inside this virtual environment…
also as mentioned earlier… it works perfectly in cron job design window with “Run Now” button… but when you schedule it, it fails silently …
Ah, sorry perhaps i missed that… You’re rigjt. Sorry.
Can’t help but is this the case also?
The accepted answer actually works fine until your python need to run a script which have to run another python binary from venv/bin directory.
IF SO Maybe search for such term then on the web. should be something with (activate) i hope / guess ,
I find activate for python env nice that it is possible but a … thing to remember for using it only sometimes. ( wen i forget to deactivate for example)
Don’t know if other here know that part, virtualmin support maybe can help you but i guess they are really busy for the moment with some update things.
So for if GPL license?
IF PRO license you can post here for support from virtualmin support is quicker.
that worked for me…
now I created one more python file, where cron job runs this file from local environment. but inside that python file I am activating environment python and executing its job…
activate_this = “/home/username/pythonenv/bin/activate_this.py”
from module import YourClass