开发者

Cron job: problem with crontab, it automatically sending me an email

开发者 https://www.devze.com 2023-01-23 04:02 出处:网络
How can 开发者_运维知识库I disable the email on the cron?Send the standard output (and standard error) of your cron job to /dev/null

How can 开发者_运维知识库I disable the email on the cron?


Send the standard output (and standard error) of your cron job to /dev/null

* * * * *  /some/cron/job 1> /dev/null 2>&1

If you'd prefer a log file, change /dev/null to a real filename instead, but be aware of the security issues. Specifically, if you're running with any sort of privileged account and the log file doesn't already exist, a hacker can pre-create a symlink in place of your log file, pointing at some other file. When your cron job runs the target of the symlink gets overwritten.


You can redirect the output to /dev/null like this:

* * * * * my_command > /dev/null

If an error occurs, you'll still get an email, though.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号