Operating System - HP-UX
1829594 Members
1753 Online
109992 Solutions
New Discussion

Re: Disable mailing of at command results

 
SOLVED
Go to solution
Anthony deRito
Respected Contributor

Disable mailing of at command results

We are running an at command that executes a shell every couple of
minutes. The shells log the results we need. It seems like by default the
at command unix mails results also. Is there a way to "turn off" the at
command's mailing feature? I noticed in the at command file (with atjobs)
there was a line :notify by mail:no.
Thanks
5 REPLIES 5
Andy Monks
Honored Contributor

Re: Disable mailing of at command results

According to the man page for at :-

stdout/stderr are mailed to the user unless it's redirected elsewhere from within the job
Rick Garland
Honored Contributor
Solution

Re: Disable mailing of at command results

Do the 2>&1 > /dev/null to redirect messages to the null bucket or to anywhere else you want.
John Palmer
Honored Contributor

Re: Disable mailing of at command results

Ensure that any standard output or standard error from the job is sent to a relevant log file or /dev/null if not required. man at says for the -m flag:-
Unless redirected elsewhere within the job, standard output and standard error produced by the job are automatically mailed to the user as well.
The Posix/Korn shell command 'exec' can be used within the script to redirect standard output and error e.g.
exec 1>/dev/null 2>&1

Hope this helps,

John
CHRIS_ANORUO
Honored Contributor

Re: Disable mailing of at command results

You can use at -r to remove the at jobs.
Set the user in /var/adm/cron/at.deny to restrict the user.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Stephen Clark_1
New Member

Re: Disable mailing of at command results

The "at" command works similarly to crontab entries. You basically need to redirect STDOUT and STDERR to something, whether it be to a log file or to /dev/null. Sometimes you may want to see the errors being generated especially if the script being executed does not have a lot of error checking included.

For example if the program being executed, for some reason, has the wrong permissions and you have the stderr/stdout going to /dev/null, you'd never know that the program was not running. Of course in your scripts you have detailed logging and know when things are running correctly. :)

i.e
program >/dev/null 2>&1

Hope this helps.
What's up with these cartoon characters??