最近使用centos6.8的crontab定时执行一个py脚本没有得到实际单独运行的效果
代码https://github.com/ansionfor/...
crontab -e 设置
脚本单独运行效果
crontab 日志有记录每分钟运行了py脚本
crontab处于启动状态
脚本的作用是保存某网站的文章到我自己远程mysql数据库中,但我测试了几天,发现没有一篇文章是通过这个定时器保存的,都是我自己手动运行脚本保存的文章
但是奇怪的是,我在crontab中放另外一个发送邮件的py脚本,却可以正常运行
代码https://github.com/ansionfor/...



1. If the subject added the sentence #!/usr/local/bin/python2.7 to xxx.py, then your crontab scheduled task definition only needs to be:
Because the first line of the script specifies the interpreter and it is already an executable script (file), there is no need for python2.7 to execute the command.
2. If you don’t write the first line to specify the environment variable, I usually write it like this because there are multiple versions in my environment
To specify the path for python execution, it is recommended that you write like this
3. Why does crontab need to specify the python path?
4. About debugging
After several tests, we came to the conclusion that there is a problem with the get_dongqiudi.py script, so the new problem is,
This script can be executed manually, but why does it not take effect in crontab?
I just rebuilt a mkfile.py file and put it in crontab to execute it regularly every minute. It can be executed normally
But once the code is changed to this, it cannot be run in crontab and can only be run manually
The following code