Operating System - HP-UX
1844007 Members
2293 Online
110226 Solutions
New Discussion

STDOUT/STDERR/cron trivia

 
SOLVED
Go to solution
Adam Garsha
Valued Contributor

STDOUT/STDERR/cron trivia

I get an Email from cron each night because a cron entry's stdout is not being properly redirected to a log file or bit-bucket.


logout


*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

. /etc/profile 1>/dev/null 2>&1; /optim/bin/sel_efta_priv -p1 -p5 -p9 -sy 1>/dev/null 2>&1 #Turn on statements for privileges



As you can see, streams 1 and 2 are being directed to /dev/null in the cron entry. Any ideas about why the "logout" is making its way through to STDOUT or STDERR?

I think the answer lies in the ".", but I can't remember the specifics on what this does in the shell. Isn't it "run the following in the current shell process"?

Thanks in advance.
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: STDOUT/STDERR/cron trivia

the cron command seems a little complex.

If this worked previously, what has changed recently?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
RAC_1
Honored Contributor
Solution

Re: STDOUT/STDERR/cron trivia

It is coming from /etc/profile. you seem to have a trap statement somewhere in the cron script. That is echoing it.
There is no substitute to HARDWORK
Adam Garsha
Valued Contributor

Re: STDOUT/STDERR/cron trivia

To Steve:

It still works fine; I have just started trimming down all the root Email that I get (from multiple hosts) and this message has been one that I haven't had time to look into before now... hence, the post.
Pete Randall
Outstanding Contributor

Re: STDOUT/STDERR/cron trivia

I have the same problem with one of my cron jobs. It also sources /etc/profile. As I recall, it's the

"trap "echo 'logout'" 0"

line that causes this. I tried removing it and that caused other problems with /etc/profile so I decided to just live with it.


Pete

Pete
Adam Garsha
Valued Contributor

Re: STDOUT/STDERR/cron trivia

Yes, it is /etc/profile and it is that trap line. I looked at a few hosts and that looks like it is standard for HP-UX. Any ideas why? What is the value of that line?

What kind of problems happen when the line is removed?
RAC_1
Honored Contributor

Re: STDOUT/STDERR/cron trivia

What that lines does is, it echos logout when it catches signal 0. when you logout, it echoes "logout"

You can take it out.

Anil
There is no substitute to HARDWORK
Pete Randall
Outstanding Contributor

Re: STDOUT/STDERR/cron trivia

Adam,

Sorry, I don't recall why I decided to live with it, but a little research into the trap command led me to this little tidbit:

root# trap
trap -- 'echo '\''logout root'\' EXIT
root#

The trap seems to still be in effect, but only for root:

$ trap
$

That leads me to believe that it was OK for regular users but caused problems for root?


Pete

Pete