本文介绍了Pytest 可以在预先安排的时间运行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 pytest 使用 python3 脚本运行我的测试,如下所示:

I am using pytest to run my tests using python3 script like below:

pytest -s test_file.py | tee -a myoutput.log

它有效.现在我想每天在特定时间运行它,我从 linux 控制台尝试了crontab -e"但失败了.我的意思是没有日志添加到myoutput.log"文件中.有人可以帮忙吗?谢谢!

It works. Now I would like to run this at a specific time everyday, I tried "crontab -e" from linux console but failed. I mean there is no log added to "myoutput.log" file. Can anyone please help? thanks!

42 00 * * * /usr/bin/pytest pytest -s /data/smc/test_file.py | tee -a myoutput.log

推荐答案

我认为可以通过使用 cron 输出来完成.例如:

I think it can be done by using cron output. eg:

42 00 * * */usr/bin/pytest pytest -s/data/smc/test_file.py >>/Your-log-path.log 2>&1

这篇关于Pytest 可以在预先安排的时间运行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 05:56