Operating System - HP-UX
1828083 Members
2666 Online
109974 Solutions
New Discussion

Output error / message to /dev/null

 
heaman1
Regular Advisor

Output error / message to /dev/null

I have a batch job that run many commands , sometimes it generate errors ( for different reasons ) , so that there are many messages pop to the console , and write to messages log , can advise if I want the batch job DO NOT output anything or just output to /dev/null ( because there are too many messages ) , what can i do ? thx
5 REPLIES 5
Nido
Trusted Contributor

Re: Output error / message to /dev/null

Hi,

cmd 2>/dev/null

Thanks,
" Let Villagers Be Happy!! "
Ganesan R
Honored Contributor

Re: Output error / message to /dev/null

Hi Heaman1,

Two kind of output we can expect from a job.
standard output and standard error.

If you want to nullify only standard output

program > /dev/null

If you want to nullify only standard error

program 2> /dev/null

If you want to nullify both std out and std error

progradm 2>&1 /dev/null
Best wishes,

Ganesh.
James R. Ferguson
Acclaimed Contributor

Re: Output error / message to /dev/null

Hi:

> If you want to nullify both std out and std error: progradm 2>&1 /dev/null

No, to discard both STDOUT and STDERR do:

# program > /dev/null 2>&1

Regards!

...JRF...
Ganesan R
Honored Contributor

Re: Output error / message to /dev/null

I agree with you James. It is my typo mistake again. sorry for that.
Best wishes,

Ganesh.
Dennis Handly
Acclaimed Contributor

Re: Output error / message to /dev/null

Rather than send all message to /dev/null, you may want to send them to a file. Or a file based on the day of the week.
Of course you will have to have a process to remove these, if they grow very large.
If you start the job once a day, then perhaps the 7 files can just be left there.