如何测试cron作业? [英] How to test a cron job?

查看:537
本文介绍了如何测试cron作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Ubuntu Linux 10.0.4。我想每6小时,每天运行一个脚本。当我发出 sudo crontab -e 时,我看到:

I'm using Ubuntu Linux 10.0.4. I want to run a script every 6 hours, every day. When I issue sudo crontab -e, I see:

# m h  dom mon dow   command
* 00,06,12,18 * * * /opt/scripts/selenium/run_nis_inf_tests.sh

但是,我没有看到我的脚本的预期结果,我甚至不确定如果它的运行。有没有办法测试,短缺等待指定的时间,脚本正常运行。或者,我如何查看脚本生成的错误? - Dave

However, I'm not seeing the expected outcome from my script, and I'm not even sure if its running. Is there a way to test, short of waiting until the specified time, that the script is running properly. Or, how can I view the errors the script is generating? - Dave

推荐答案

您可以将MAILTO变量更新为您的电子邮件地址,cron应通过电子邮件向您发送任何STDOUT和STDERR输出。还要检查您的syslog文件/ var / log / messages以查看脚本是否由cron执行。

You can update the MAILTO variable to your email address, and cron should email you any STDOUT and STDERR output. Also check your syslog file /var/log/messages to see if the script is being executed by cron.

-Tony

这篇关于如何测试cron作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆