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

查看:84
本文介绍了如何记录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天全站免登陆