Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What dose mean dev/null and dev/null 2>&1 ? if i run php -q /http/get_pdf.php

sorry for my short question when we run this file from url it will create a .pdf file and mail, we are looking to send a mail using cron in that case we need to run one pdf report for one time.

suppose goto url it will ask me mail id once we add mail id it will generate report what you ask for from drop down manu like what is sale for week? it will be mail on mail id, we don't want to from url we want happend from cron. Can same pls help me.

share|improve this question
Are you be a bit more clear. – topdog Aug 27 '10 at 15:43

I'm assuming you're looking for the difference between something like this:

$ php -q /http/get_pdf.php > /dev/null

and this:

$ php -q /http/get_pdf.php > /dev/null 2>&1

The first version redirects stdout to /dev/null, and the second redirects both stdout and stderr to /dev/null.

share|improve this answer
yes but same time i need to out to mail bcoz that get_pdf.php will create a .pdf file as report in one of the folder that i need to mail that pdf using cron – neolix Aug 27 '10 at 15:54
Well technically the 2>&1 redirects stderr to stdout, which is redirected by the > /dev/null part. But yes, they both end up going to the bit-bucket. – Chris S Sep 9 '10 at 12:40

When you have a command like:

COMMAND > /dev/null 2>&1

The "> /dev/null" part says to redirect all Standard Output from the command to the bit bucket. The "2>&1" part says redirect all Standard Error to Standard Out (which in turn gets redirect to /dev/null)

So essentially that will suppress all output.

share|improve this answer

You mean something like /command >/dev/null 2>&1?

  • /command: will be run
  • >/dev/null: redirect standard output to nothing (/dev/null is a special null device, that means no output will be shown)
  • 2>&1: redirect errors to stdout.

If you are running this as cron, stdout is often a mail (if errors occurs, mail to administrator)

share|improve this answer
yes i want to run as cron thanks for your quick reply how do run in cron can send me step pls. thanks in advance!! – neolix Aug 27 '10 at 15:52
This is basically universal syntax for stdout and stderr redirection. I have been quite surprised it works in not only every Unix/Linux variant I use (not so surprising), but Windows. That is universal, haha. – songei2f Aug 27 '10 at 15:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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