python h.py
在终端的 anaconda evoronment 中执行它,pythons脚本就会运行。h.py 在主目录中crontab -e
在 crontab 里面:
#[long descriptional text]
...
53 13 * * * cd /home/ && /home/user/anaconda3/envs/rapids/bin/python h.py
这 alos 什么都不做 没有错误消息
我也尝试了以下解决方案
32 14 * * * cd /home/Documents && /home/user/anaconda3/envs/rapids/bin/python h.py
34 14 * * * cd /home/Documents && /home/anaconda3/envs/rapids/bin/python h.py 2>&1
https://stackoverflow.com/a/64470729/1027059044 14 * * * cd /home/Documents && /home/user/anaconda3/envs/rapids/bin/python h.py >> ~/cron.log 2>&1
58 14 * * * /home/Documents && /home/user/anaconda3/envs/rapids/bin/python home/Documents/h.py >> ~/cron.log 2>&1
59 14 * * * /home/Documents && /home/anaconda3/envs/rapids/bin/python home/Documents/h.py >> ~/cron.log 2>&1
58 14 * * * /home/user/anaconda3/envs/rapids/bin/python home/Documents/h.py
10 15 * * * /home/anaconda3/envs/rapids/bin/python home/Documents/h.py
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
我也阅读了以下解决方案,但没有任何效果
如果Python文件只需要python(不需要其他库)
56 16 * * * /home/MY_ACTUAL_USERNAME/anaconda3/envs/rapids/bin/python /home/MY_ACTUAL_USERNAME/Documents/h.py
如果 Python 文件需要 anaconda 环境中的其他 Python 库:
nano my_sehell_file_name.sh
#!/bin/bash
#conda activate rapids WRONG
source ~/anaconda3/bin/activate MY_ANACONDA_ENVIRONMENT_NAME #correct
#python Documents/my_python_file_name.py WRONG SEPARATLY GO TO FOLER WHTAN EXECUTE EITH python
cd ~/Documents/folder_where_python_file_is/ #correct
python my_python_file_name.py #correct
conda deactivate
corntab -e
43 21 * * * /home/MY_ACTUAL_USERNAME/my_sehell_file_name.sh
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句