- I want to scedual a task with crontab to run a python file in a specific anaconda environment every day at a certain time.
- I also have a python script to do so.
- The pythons script runs if I jsut execute it with
python h.pyin the anaconda evoronment in terminal. h.py is in the home directory - I am usaing Ubuntu 20.04, and i havent refreshed on intalled any new cron or crontab
- I have tried the following commands to get it work but they just do Nothing (the result should be a folder and it is learly not has been created)
crontab -e
Inside the crontab:
#[long descriptional text]
...
53 13 * * * cd /home/ && /home/user/anaconda3/envs/rapids/bin/python h.py
this alos does nothing no error message
I have also tried the following solutions
32 14 * * * cd /home/Documents && /home/user/anaconda3/envs/rapids/bin/python h.py34 14 * * * cd /home/Documents && /home/anaconda3/envs/rapids/bin/python h.py 2>&1https://stackoverflow.com/a/64470729/1027059044 14 * * * cd /home/Documents && /home/user/anaconda3/envs/rapids/bin/python h.py >> ~/cron.log 2>&1- not worked with normal anaconda - https://unix.stackexchange.com/a/572951/400960
58 14 * * * /home/Documents && /home/user/anaconda3/envs/rapids/bin/python home/Documents/h.py >> ~/cron.log 2>&159 14 * * * /home/Documents && /home/anaconda3/envs/rapids/bin/python home/Documents/h.py >> ~/cron.log 2>&158 14 * * * /home/user/anaconda3/envs/rapids/bin/python home/Documents/h.py10 15 * * * /home/anaconda3/envs/rapids/bin/python home/Documents/h.py- Run this for analytics purpose with no results (no file has been created, no printout in terminal)
36 15 * * * /home/anaconda3/envs/rapids/bin/python -c "import sys; sys.stdout.write('out\n'); sys.stderr.write('err\n')" >> /home/so_test.log 2>&1
I have also read teh following solutions but nothing have realy worked
- 1 thinga that may someve that issue is taht I am not sure if I need to isntall a daemon for crontab, like it recomended here: https://askubuntu.com/a/1048365/984498 but I culd not find cronie install for ubuntu
- https://unix.stackexchange.com/questions/300128/how-can-i-run-a-python-script-using-anaconda-from-the-command-line
- https://unix.stackexchange.com/questions/574085/crontab-service-file-not-found-despite-installed-and-configured-crontab
- https://askubuntu.com/questions/1021622/crontab-doesnt-run-python-script
- Execute Python script via crontab
- Crontab python script does not run (with anaconda on linux server)
/home/user/anaconda3/envs/rapids/bin/python /home/h.py. There's no need tocd, if you need to be in/homeyou should set thecwdin the script.58 14 * * * /home/user/anaconda3/envs/rapids/bin/python home/Documents/h.pywith whatever output redirects you want. You should probably also expand the~for the log. The link I gave is how to change the current working directory of a python script, it is the equivalent ofcdbut within a python script.* 15 * * * /home/user/anaconda3/envs/rapids/bin/python -c "import sys; sys.stdout.write('out\n'); sys.stderr.write('err\n')" >> /home/user/so_test.log 2>&1this works and outputs bothstdoutandstderrto the file/home/user/so_test.log. Try adding this to your crontab and see if it runswhich pythonand that will tell you where the executable file is. That should be the first item after the time spec, for me it's/home/alex/envs/test_env/bin/python. yours will be different. I have copied the path that you have given in your question!/on the path to your python script.