6

Can someone explain to me what is the meaning of "2>&1" doing here in the below cron job

0 23 * * * wget -q -O /dev/null "https://example.com/index.php" > /dev/null 2>&1

1 Answer 1

6

It means that stderr (2 - containing error messages from the executed command or script) is redirected (>&) to stdout (1 - the output of the command) and that the latter is being redirected to /dev/null (the null device).

This way you can suppress all messages that might be issued by the executed command. In cron this is often done to avoid being spammed by lots of irrelevant messages from service scripts. Nevertheless be careful with this as some messages might be important.

More information on output redirects can be found in The Linux Documentation Project here and here. The null device is described here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.