Solved Stop only one cron job from sending emails but continue log to file?

Hi,

I have one job in crontab that I want to disable emails for, but I want to continue to log to a file.

This is what I have:

Code:
root@srv06:/# crontab -e
0 0 * * * service apache24 restart >> /var/log/apache-restart.log

I can't use the MAILTO="" variable because that will stops all crontab emails, and >> /dev/null >> 2>&1 disables file logging?
 
and >> /dev/null >> 2>&1 disables file logging?
If you redirect everything to /dev/null, yes. But why don't you just redirect STDERR to STDOUT and log to /var/log/apache-restart.log?

Code:
0 0 * * * service apache24 restart >> /var/log/apache-restart.log 2>&1
 
If you redirect everything to /dev/null, yes. But why don't you just redirect STDERR to STDOUT and log to /var/log/apache-restart.log?

Code:
0 0 * * * service apache24 restart >> /var/log/apache-restart.log 2>&1
Didn't know you could do it like that, thanks for the input!
 
Is there a way to replicate the behavior of -n for crontab in FreeBSD 10.3? I don't think it appeared until FreeBSD 12 or thereabout (either that or the documentation was not updated).
 
Back
Top