I have many shell and python scripts on my crontab that ending either with:
command.sh > /dev/null 2>&1
or
command.sh 2>&1 >/dev/null
I know that:
>
is for redirect
/dev/null
is a black hole where any data sent, will be discarded
2
is the file descriptor for Standard Error
>
is for redirect
&
is the symbol for file descriptor (without it, the following 1 would be considered a filename)
1
is the file descriptor for Standard Out
Therefore command.sh >/dev/null 2>&1
redirects the output of my program to /dev/null. Include both the Standard Error and Standard Out.
both have the same result and work fine, but why do some use the first type and some use the other?