1833003 Members
1889 Online
110048 Solutions
New Discussion

Re: at command stop mail

 
SOLVED
Go to solution
Dave La Mar
Honored Contributor

at command stop mail

Sorry people, I have tried suggestions from -
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xf06b7e990647d4118fee0090279cd0f9,00.html

and I still get mail from root.
Command -
at -f file_name now >2&1 >/dev/null
The command is executed from with a non root user's script.
I have no need for the mail since I capture errors else where.
I guess I need another set of eyes because even directing the output to a file results in an email sent.

Thanks for any input.
dl
"I'm not dumb. I just have a command of thoroughly useless information."
5 REPLIES 5
Wilfred Chau_1
Respected Contributor
Solution

Re: at command stop mail

Tried this
>/dev/null >2&1
Deepak Extross
Honored Contributor

Re: at command stop mail

Dave,
Looks like a typo.
You should be doing this:
at -f file_name now 2>&1 >/dev/null
not this:
at -f file_name now >2&1 >/dev/null

Better still, I prefer to use:
at -f file_name now 1>/dev/null 2>/dev/null
No ambiguity, no confusion.
Darrell Allen
Honored Contributor

Re: at command stop mail

Hi Dave,

I'm not at a system to try this now but let's assume >2&1 was simply a typo you made when posting your question.

There's a difference between the following two command lines:
command >/dev/null 2>&1
command 2>&1 >/dev/null

The first command line redirects stdout to /dev/null then redirects stderr to where ever stdout is going (which was just set to /dev/null). So stdout and stderr get sent to /dev/null.

The second command line redirects stderr to where ever stdout is going at the time (by default the at job sends stdout to mail) then redirects stdout to /dev/null. Only stdout is redirected to /dev/null. Stderr was not affected by the redirect of stdout.

"man sh-posix" has more info I believe).

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Deepak Extross
Honored Contributor

Re: at command stop mail

Darrel's right - I verified it with a small test.

For this reason, I'm a strong supporter of the syntax
1>/dev/null 2>/dev/null
Dave La Mar
Honored Contributor

Re: at command stop mail

Thanks to all.
Each scenario appears to work.
Yes I did send a typo, but I tried so many combinations, I no longer could see the forest.
Part of my problem was the user id I was using to test.
I have set nearly all my users
in a mail db to redirect the mail to Outlook Express. This appeared to continue to send the mail regardless of the suggested method of executing the redirection.
The user that will need to execute this command is not in that db and no mail or mail error seems to appear for the user or in root.
In any event, thanks to all that replied to my frustration.
dl
"I'm not dumb. I just have a command of thoroughly useless information."