I understand that this command attempts to write to nowhere or a null device but what does 2>&1
mean here?
wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
I understand that this command attempts to write to nowhere or a null device but what does 2>&1
mean here?
wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
2
refers to the second file descriptor of the process, i.e. stderr
.
>
means redirection.
&1
means the target of the redirection should be the same location as the first file descriptor, i.e. stdout
.
So > /dev/null 2>&1
first redirects stdout
to /dev/null
and then redirects stderr
there as well. This effectively silences all output (regular or error) from the wget
command.
::edit:: Here is an excellent quick reference for you.
>
do not matter, but spaces within the 2>&1
probably do matter (I can't recall).
– dg99
Nov 07 '13 at 17:32
&>/dev/null
– Joseph R.
Nov 07 '13 at 17:32