python 脚本在crontab里无法执行,但该脚本手动可以运行

解决方法:

建立一个shell文件,设置python执行的绝对路径,在shell文件里执行python文件,再在crontab里执行crontab定时任务

vim test.sh

. ~/.bash_profile

PYTHON3=/u/pareng/bin/python3

$PYTHON3 ~/test1.py

crontab -e

00 18 * * 5 . /etc/profile;/bin/sh test.sh  #每周五18:00执行


版权声明:本文为weixin_44799327原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。