I have a (root) cron job definition like the following:<br><br>0 0 * * * /usr/bin/clamscan --no-summary -r --reload --log=/var/log/clamav/clamscan.log -i / | mail -s "Virus scan found something" <a href="mailto:davidmichaelkarr@gmail.com">davidmichaelkarr@gmail.com</a><br>
<br>This works fine when it finds something (I tested it with a fake virus file), but what I didn't expect is that "mail" sends the mail even if the output is empty. It would be straightforward to extend this into a shell script that writes the output to a temp file, then only pipes it into "mail" if the output is non-empty, and then deletes the temp file.  Is there an "easier" (that can mean many things) way to do this?<br>