Mar 22

Silence stdout for an entire shell script

Tag: Linux, System AdministrationDan @ 6:17 pm

To silence stdout in a Linux shell script use the following line:

exec 1>/dev/null

This redirects the file stream to the /dev/null device which silently swallows the output.

This is useful if for instance you are writing a cron job which you want to have log it’s steps while you are developing or debugging it, but don’t want any output except the stderr once it’s running.

Leave a Reply

*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation