[英]Is time.sleep a good way to run a python script every day?
I would like to run a python script every day in my EC2 Linux instance.我想每天在我的 EC2 Linux 实例中运行 python 脚本。 My idea is to run my python script with
time.sleep()
at the end and detach the screen using screen
Linux command.我的想法是在最后运行带有 time.sleep
time.sleep()
的 python 脚本,并使用screen
Linux 命令分离屏幕。 Is there a more efficient way to do this?有没有更有效的方法来做到这一点?
If you're looking to run a command at a specific time each day take a look at crontab .如果您希望在每天的特定时间运行命令,请查看crontab 。 By using this you can set a schedule for when the script should run.
通过使用它,您可以设置脚本何时运行的时间表。
If you do have any output for the script then make sure that you pipe it to a log file.如果您确实有任何 output 用于脚本,请确保将 pipe 写入日志文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.