I'm not sure if this is the right forum for this question but.......
I've set up a cron job on redhat and set it up to send stdout to one log file and stderr to another... for example:
0 7,13,19 * * * /root/scripttorun.sh >/root/scripttorun.log 2> /root/error.log
I'm also setting up a script to mail the error.log file if it exists
perl /root/smtp_send.pl -t
user@domain.co.uk -s " Error for script on $HOSTNAME" -a /root/error.log
(smtp_send.pl uses MIME::Lite - the -t,-s -a are variables which get feed in to perl script to specify who the mail should goto, what the sibject is and what file to attach)
I really only want the cron job to create error.log if there are actually any errors but everytime the cron job runs it creates an empty error.log.
Is this what you would expect to see??? i.e will it always create an empty error.log file? Can anyone suggest a way to amend the second script so it only attched the file if is is larger than 0kb?
Thanks,
Emma