Can Pytest run at a pre-scheduled time?

2019-07-10 17:05发布

问题:

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

pytest -s test_file.py | tee -a 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

回答1:

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