Operating System - HP-UX
1820565 Members
2099 Online
109626 Solutions
New Discussion юеВ

at job and e-mail notification

 
SOLVED
Go to solution
navin
Super Advisor

at job and e-mail notification

Every time when the at job runs ..it send an e-mail or saves message in /var/mail/useraccount - i want to disable this - is it possible
thanks much
Learning ...
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: at job and e-mail notification

Hi:

Like any 'crontask' running 'at' by default redirects STDOUT and STDERR as mail to the user who initiated the job.

To eliminate this, you need to redirect STDERR (fd #2) and/or STDOUT (fd #1) to a file or to '/dev/null'.

You could add something like this to your script:

[ -t 0 ] || exec 1> /dev/null 2>&1

This says if the process isn't associated with a terminal then redirect both STDOUT and STDERR to /dev/null. This eliminates your mail when your script is run via 'at' or 'cron' but not when run interactively from the command line.

Regards!

...JRF...
navin
Super Advisor

Re: at job and e-mail notification

Thanks
Learning ...
Dennis Handly
Acclaimed Contributor

Re: at job and e-mail notification

One caution with JRF's redirection to /dev/null, is that you better not be having any unexpected errors.
You may want to look at your script and only redirect the output on commands you absolutely don't care about.

Or take JRF's idea and redirect to the same file. That way you at least have one run's worth. Or append to the same file and clean out weekly or monthly.