euglug.org

[Eug-lug] cron and output

작성자

카테고리:



Allen C BrownMon Jun 27 12:03:47 PDT 2005

Rob Hudson said the following on 06/24/2005 10:19 AM:
> Neil Parker wrote:
> 
>>Rob Hudson wrote,
>>
>>
>>>How does one disable the output of certain cron jobs?  I have some 
>>>backup scripts running and other things and don't need to see all of 
>>>that stuff in an email.  Can I silently discard the output of those 
>>>scripts that run?
>>
>>
>>The incantation I usually use is this:
>>
>>     myscript.sh >/dev/null 2>&1
>>
>>where "myscript.sh" is the script to be run by the cron job.  This goes in
>>the crontab file, in the "command to be run" field.
>>
>>The ">/dev/null" discards the standard output, and "2>&1" says to send the
>>standard error to the same place as the standard output.
> 
> 
> That's the one I'm used to seeing.  Thanks for the explanation.  &1 I 
> guess can be thought of as a reference to where stdout is going.
> 
> Thanks,
> Rob

 > and 1> mean redirect stdout
2> means redirect stderr

 >&1 means merge the stream into stdout

So 2>&1 means merge stderr into stdout.  You can then do
whatever you want with stdout.
-- 
Allen Brown
   work: Agilent Technologies      non-work: http://www.peak.org/~abrown/
         allen_brown at agilent.com	            abrown at peak.org
   Everything should be made as simple as possible, but no simpler.
     ---Albert Einstein