HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   What is the usefulness of /dev/null 2>&1 in Cron? (http://www.howtoforge.com/forums/showthread.php?t=60842)

Shine 7th March 2013 00:51

What is the usefulness of /dev/null 2>&1 in Cron?
 
For instance,
if I have a .pl script, or .php script, I could simply execute on my terminal
Code:

]# php /path/to/my/script.php
and make the code executed.

So, adding a cron job to run every 5 minutes for this script, can be written like this:
Code:

5 * * * * php /path/to/my/script.php
And the question is:
what is the difference between that statement, and, say:
Code:

5 * * * * /usr/bin/php /path/to/my/script.php > /dev/null 2>&1
I've searched the web for a detailed explanation but, I cannot find anything.
Would you explain me this please?
Or show me a page with this issue.

Thanks a lot.

TiTex 7th March 2013 07:16

Quote:

5 * * * * /usr/bin/php /path/to/my/script.php > /dev/null 2>&1
as far as i know this redirects ( > ) any output from script.php to /dev/null ... which is nowhere (like a black hole) , and stderr ( 2 ) is redirected to ( >&1 ) stdout which is already redirected to nowhere , basicly it makes your script run silently and doesn't generate any output or error log/file

i hope i'm not mistaken


All times are GMT +2. The time now is 08:38.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.