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.
Reply
 
Thread Tools Display Modes
  #1  
Old 7th March 2013, 00: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
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.

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

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

Bookmarks

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 14:49
Ispconfig not saving ftp stats MasteRTriX General 4 19th March 2010 15:16
Shell Script Execution Problem giganet Programming/Scripts 1 23rd December 2008 15:04
ISP Config hesitation when opening web pages frankb Installation/Configuration 7 15th December 2008 13:06
The Perfect Setup - CentOS 4.4 (32-bit), How to add Virtual Users? joshenry Installation/Configuration 10 25th January 2007 20:00


All times are GMT +2. The time now is 01:57.


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