Silence stdout for an entire shell script

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.