如何记录 cron 作业? [英] How to log cron jobs?

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

问题描述

我想知道如何准确地查看 cron 作业在每次执行时都在做什么.日志文件位于何处?或者我可以将输出发送到我的电子邮件吗?我已将电子邮件地址设置为在 cron 作业运行时发送日志,但我还没有收到任何消息.

I want to know how I can see exactly what the cron jobs are doing on each execution. Where are the log files located? Or can I send the output to my email? I have set the email address to send the log when the cron job runs but I haven't received anything yet.

推荐答案

* * * * * myjob.sh >> /var/log/myjob.log 2>&1

将 cron 作业的所有输出记录到/var/log/myjob.log

will log all output from the cron job to /var/log/myjob.log

您可以使用 mail 发送电子邮件.大多数系统会通过电子邮件将未处理的 cron 作业输出发送给 root 或相应的用户.

You might use mail to send emails. Most systems will send unhandled cron job output by email to root or the corresponding user.

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

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