![](/img/trans.png)
[英]Make a batch file to run python script for a certain amount of time and then auto-closes after
[英]How to execute one python file for a certain amount of time and after that, run another?
我有两个脚本; 第一个挖掘大量数据,第二个分析数据。 我希望第一个文件运行大约2个小时左右,然后让第二个文件运行一次。
我知道os.system()
并不是解决此问题的非常安全的方法。 我也想了解为什么?
也许,我应该提到两个Python脚本需要执行才能调用main函数。
谢谢你的帮助!
如果使用Linux环境,则可以在将脚本添加到cron作业后执行脚本。
要执行主要功能,请将初始代码放在此之后(在python中):
if __name__ == '__main__':
#your code
如果您在Windows上并且很懒,则可以创建一个
python first_task.py
SLEEP 7200
python second_task.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.