Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要一个 cron 作业来每天扫描日志并通过电子邮件报告所有错误行。我可以处理 PHP,但我是 Unix 新手。是否有任何快速的 Unix 命令可以将输出写入另一个文件,我可以使用另一个工作通过电子邮件发送该文件?
当然,
您必须将 STDOUT 和 STDERR 重定向到文件...
请参阅以下 crontab 示例!
* * * * * root script.php 2>&1 /tmp/script-output.log | mail -s 'Subject' to@test.com
再见!