*/5 * * * * /usr/local/bin/php somephpfile.php>> /dev/null 2>&1

What exactly does the dev/null 2 mean?



It's redirecting STDER (Standard Error) to go along with STDOUT (Standard Out). In short, both of them are redirected to /dev/null, meaning no output from the program is ever displayed.

  • 1
    So that you don't get an email if the command output something :) – Nicolas Viennot Jun 24 '10 at 23:54

2>&1 means "send stderr to stdout."

>>/dev/null means "append stdout to /dev/null," which is a way of hiding program output by sending it into /dev/null, whose only purpose in life is to act like a black hole for data. (Strictly speaking, for /dev/null, >>/dev/null is the same as >/dev/null.)

These rules are evaluated from right to left, so in combination they say, "hide everything output to stderr and stdout." A common mistake is to specify them in the reverse order, which will not hide the stderr output.

Also worth knowing: you can explicitly send both streams to /dev/null by saying 1>/dev/null 2>/dev/null or &>/dev/null rather than sending stderr to stdout and then sending stdout to /dev/null.

  • this was the best answer as it was explained the best. However I had already picked an answer :S – jini Jun 24 '10 at 22:25

It means redirect standard error and standard output to nothing (throw it away).

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.