<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" > <channel><title>Comments on: Meaning of /dev/null 2&gt;&amp;1 in Crontab’s Cron Job</title> <atom:link href="http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/feed/" rel="self" type="application/rss+xml" /><link>http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/</link> <description>What&#039;s going on Internet?</description> <lastBuildDate>Mon, 06 Feb 2012 19:41:35 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Chris Sheldon</title><link>http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/comment-page-1/#comment-1153</link> <dc:creator>Chris Sheldon</dc:creator> <pubDate>Thu, 27 May 2010 17:41:10 +0000</pubDate> <guid isPermaLink="false">http://markus.revti.com/index.php/2008/06/11/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/#comment-1153</guid> <description>Kalin is right. STDIN is 0.One other point to add. That is the difference between &quot;&gt;/dev/null 2&gt;&amp;1&quot; and &quot;2&gt;&amp;1 &gt;/dev/null&quot;As posted above, &quot;&gt;/dev/null 2&gt;&amp;1&quot;: - redirects stdout(1) to the file /dev/null - THEN redirects stderr(2) to stdout(1)The other, &quot;2&gt;&amp;1 &gt;/dev/null&quot;: - redirects stderr(2) to stdout(1) - THEN redirects stdout to the file /dev/nullNow, that all sounds reasonable. It also sound like both statements accomplish the same thing.... but they don&#039;t. The assignment of descriptors is absolute. If you assign stdout to /dev/null, then later assignments follow that same path. If you assign stderr to stdout, all stderr messages will go to the stdout device. If you later assign stdout messages to /dev/null, the messages going to stderr will still get sent to the stdout device because &quot;&gt;/dev/null&quot; doesn&#039;t repoint the device, it repoints the stream.You don&#039;t believe me. Ok, that;s fine. Bust out gcc and see for yourself and welcome to the funky world of unix descriptors... where 256 is no longer the limit (that&#039;s a descriptor joke).flinux:~% cat test.c #include main() { write(1, &quot;hello &quot;, 6); write(2, &quot;world\n&quot;, 6); }flinux:~% gcc -o test test.c flinuk:~% ./test hello world flinux:~% ./test &gt;/dev/null world flinux:~% ./test &gt;/dev/null 2&gt;&amp;1 flinux:~% ./test 2&gt;&amp;1 &gt;/dev/null world</description> <content:encoded><![CDATA[<p>Kalin is right. STDIN is 0.</p><p>One other point to add. That is the difference between &#8220;&gt;/dev/null 2&gt;&amp;1&#8243; and &#8220;2&gt;&amp;1 &gt;/dev/null&#8221;</p><p>As posted above, &#8220;&gt;/dev/null 2&gt;&amp;1&#8243;:<br /> - redirects stdout(1) to the file /dev/null<br /> - THEN redirects stderr(2) to stdout(1)</p><p>The other, &#8220;2&gt;&amp;1 &gt;/dev/null&#8221;:<br /> - redirects stderr(2) to stdout(1)<br /> - THEN redirects stdout to the file /dev/null</p><p>Now, that all sounds reasonable. It also sound like both statements accomplish the same thing&#8230;. but they don&#8217;t. The assignment of descriptors is absolute. If you assign stdout to /dev/null, then later assignments follow that same path. If you assign stderr to stdout, all stderr messages will go to the stdout device. If you later assign stdout messages to /dev/null, the messages going to stderr will still get sent to the stdout device because &#8220;&gt;/dev/null&#8221; doesn&#8217;t repoint the device, it repoints the stream.</p><p>You don&#8217;t believe me. Ok, that;s fine. Bust out gcc and see for yourself and welcome to the funky world of unix descriptors&#8230; where 256 is no longer the limit (that&#8217;s a descriptor joke).</p><p>flinux:~% cat test.c<br /> #include<br /> main()<br /> {<br /> write(1, &#8220;hello &#8220;, 6);<br /> write(2, &#8220;world\n&#8221;, 6);<br /> }</p><p>flinux:~% gcc -o test test.c<br /> flinuk:~% ./test<br /> hello world<br /> flinux:~% ./test &gt;/dev/null<br /> world<br /> flinux:~% ./test &gt;/dev/null 2&gt;&amp;1<br /> flinux:~% ./test 2&gt;&amp;1 &gt;/dev/null<br /> world</p> ]]></content:encoded> </item> <item><title>By: Criss Leonte</title><link>http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/comment-page-1/#comment-1125</link> <dc:creator>Criss Leonte</dc:creator> <pubDate>Tue, 27 Apr 2010 15:14:53 +0000</pubDate> <guid isPermaLink="false">http://markus.revti.com/index.php/2008/06/11/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/#comment-1125</guid> <description>Ah, nevermind my comment, I didn&#039;t read all the thread first :) ye that makes sense.</description> <content:encoded><![CDATA[<p>Ah, nevermind my comment, I didn&#8217;t read all the thread first <img src='http://markus.revti.com/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> ye that makes sense.</p> ]]></content:encoded> </item> <item><title>By: Criss Leonte</title><link>http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/comment-page-1/#comment-1124</link> <dc:creator>Criss Leonte</dc:creator> <pubDate>Tue, 27 Apr 2010 15:13:02 +0000</pubDate> <guid isPermaLink="false">http://markus.revti.com/index.php/2008/06/11/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/#comment-1124</guid> <description>Hey thanks for the info, I&#039;ve been curious about 2&gt;&amp;1 too. I still don&#039;t see the reason why the STDERR is redirected to STDOUT, maybe to prevent linux from logging it!?</description> <content:encoded><![CDATA[<p>Hey thanks for the info, I&#8217;ve been curious about 2&gt;&amp;1 too. I still don&#8217;t see the reason why the STDERR is redirected to STDOUT, maybe to prevent linux from logging it!?</p> ]]></content:encoded> </item> <item><title>By: Kalin Mandaliev</title><link>http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/comment-page-1/#comment-1000</link> <dc:creator>Kalin Mandaliev</dc:creator> <pubDate>Sun, 24 Jan 2010 23:24:33 +0000</pubDate> <guid isPermaLink="false">http://markus.revti.com/index.php/2008/06/11/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/#comment-1000</guid> <description>In this line , there is a mistake &quot;The last part of the statement “2&gt;&amp;1? redirects the STDERR (2) to STDIN (1) which is already redircted to /dev/null.&quot; It should be STDERR (2) to STDOUT (1).Best Regards, Kalin Mandaliev</description> <content:encoded><![CDATA[<p>In this line , there is a mistake &#8220;The last part of the statement “2&gt;&amp;1? redirects the STDERR (2) to STDIN (1) which is already redircted to /dev/null.&#8221; It should be STDERR (2) to STDOUT (1).</p><p>Best Regards,<br /> Kalin Mandaliev</p> ]]></content:encoded> </item> <item><title>By: NorB</title><link>http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/comment-page-1/#comment-868</link> <dc:creator>NorB</dc:creator> <pubDate>Tue, 01 Sep 2009 10:52:24 +0000</pubDate> <guid isPermaLink="false">http://markus.revti.com/index.php/2008/06/11/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/#comment-868</guid> <description>Linux was bulit mainly with the C programming language.In the C programming language a program has three data streams which can be handled separately : 0 means STDIN (STandarD INput) which is usually the keyboard; 1 means STDOUT (STandarD OUTput) which is the monitor; 2 means STDERR (STandarD ERRor) which is usually also the monitor by default.A program e.g. X by default prints it&#039;s output to STDOUT, to the monitor. In the &quot;X &gt;/dev/null 2&gt;&amp;1&quot; statement, the first part &quot;X &gt;/dev/null&quot; redirects X&#039;s output from STDOUT to the /dev/null file which is something like a &quot;bottomless hole&quot; in Linux. What goes there never comes back. But X&#039;s STDERR isn&#039;t redirected yet so X&#039;s error messages will still be printed to the monitor. The last part of the statement &quot;2&gt;&amp;1&quot; redirects the STDERR (2) to STDIN (1) which is already redircted to /dev/null. So none of them prints to the monitor any more. (We have to add the &quot;&amp;&quot; sign before the number 1 otherwise STDERR (2) would be redirected to a simple file called 1 in the same directory instead of STDOUT.)</description> <content:encoded><![CDATA[<p>Linux was bulit mainly with the C programming language.</p><p>In the C programming language a program has three data streams which can be handled separately :<br /> 0 means STDIN (STandarD INput) which is usually the keyboard;<br /> 1 means STDOUT (STandarD OUTput) which is the monitor;<br /> 2 means STDERR (STandarD ERRor) which is usually also the monitor by default.</p><p>A program e.g. X by default prints it&#8217;s output to STDOUT, to the monitor.<br /> In the &#8220;X &gt;/dev/null 2&gt;&amp;1&#8243; statement, the first part &#8220;X &gt;/dev/null&#8221; redirects X&#8217;s output from STDOUT to the /dev/null file which is something like a &#8220;bottomless hole&#8221; in Linux. What goes there never comes back.<br /> But X&#8217;s STDERR isn&#8217;t redirected yet so X&#8217;s error messages will still be printed to the monitor.<br /> The last part of the statement &#8220;2&gt;&amp;1&#8243; redirects the STDERR (2) to STDIN (1) which is already redircted to /dev/null.<br /> So none of them prints to the monitor any more.<br /> (We have to add the &#8220;&amp;&#8221; sign before the number 1 otherwise STDERR (2) would be redirected to a simple file called 1 in the same directory instead of STDOUT.)</p> ]]></content:encoded> </item> <item><title>By: Chris</title><link>http://markus.revti.com/2008/06/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/comment-page-1/#comment-862</link> <dc:creator>Chris</dc:creator> <pubDate>Mon, 24 Aug 2009 17:07:28 +0000</pubDate> <guid isPermaLink="false">http://markus.revti.com/index.php/2008/06/11/meaning-of-devnull-21-in-crontab%e2%80%99s-cron-job/#comment-862</guid> <description>i&#039;m still confused! what does STDIN, STDOUT, and STDERR mean ? and what do they do ?</description> <content:encoded><![CDATA[<p>i&#8217;m still confused! what does STDIN, STDOUT, and STDERR mean ? and what do they do ?</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 3/16 queries in 0.008 seconds using disk: basic
Object Caching 490/493 objects using disk: basic

Served from: markus.revti.com @ 2012-02-12 05:37:13 -->
