Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 7th March 2013, 01:51
Shine Shine is offline
Junior Member
Join Date: Mar 2013
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
]# 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:
5 * * * * php /path/to/my/script.php
And the question is:
what is the difference between that statement, and, say:
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.

Last edited by Shine; 7th March 2013 at 01:52. Reason: bad typing
Reply With Quote
Sponsored Links
Old 7th March 2013, 08:16
TiTex TiTex is offline
Senior Member
Join Date: Aug 2011
Location: Cluj-Napoca,Romania
Posts: 125
Thanks: 0
Thanked 18 Times in 17 Posts
Send a message via Skype™ to TiTex

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
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Doesnt update zones almere General 20 16th November 2012 15:49
Ispconfig not saving ftp stats MasteRTriX General 4 19th March 2010 16:16
Shell Script Execution Problem giganet Programming/Scripts 1 23rd December 2008 16:04
ISP Config hesitation when opening web pages frankb Installation/Configuration 7 15th December 2008 14:06
The Perfect Setup - CentOS 4.4 (32-bit), How to add Virtual Users? joshenry Installation/Configuration 10 25th January 2007 21:00

All times are GMT +2. The time now is 14:28.

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