简体   繁体   English

Crontab运行python脚本

[英]Crontab running python scripts

So im trying to make my ec2 instance to automatically run a python script that through Google API generates a csv with Google Analytics data. 因此,我试图使我的ec2实例自动运行python脚本,该脚本通过Google API生成包含Google Analytics(分析)数据的csv。 When i run: 当我跑步时:

python /path/script.py python /path/script.py

it works fine but i set up this line in crontab 它工作正常,但我在crontab中设置了这一行

@reboot python /path/script.py @重启python /path/script.py

And even when the file is generated non data shows up, i believe at some point the script is failing. 而且即使生成文件时也不会显示数据,我相信脚本有时会失败。 Any idea what could be causing this? 知道是什么原因造成的吗? Or how can i debug the problem? 或者我该如何调试问题? is there a log of the instance start so i can see what happens after crontab run the line? 是否有实例启动的日志,以便我可以看到crontab运行该行之后会发生什么?

将std_err和std_out重定向到一个单独的文件。

@reboot python /path/script.py 2>&1 /tmp/<file.log>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM