From browsing the web I've noticed two variations for the command to initiate the WordPress cron jobs from cPanel.
Please could someone explain the difference and which is the correct/best option to use?
wget -qO- https://www.mydomain.co.uk/wp-cron.php &> /dev/null
wget -q -O - https://www.mydomain.co.uk/wp-cron.php?doing_wp_cron >/dev/null 2>&1
Thanks
Sure, I would love to explain the concept:
>
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 >/dev/null 2>&1
is redirect the output of your program to /dev/null
. Include both the Standard Error and Standard Out.
cron
will only email you if there is some output from you job. With everything redirected to null
, there is no output and hence cron
will not email you.
Hope I explained it more clearly.