[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: logging a bash script using sudo and time



Brian McKee wrote:
> Hi All
> 
> I regularly run a script with time and sudo.  e.g.
>> time sudo echo 'hi mom'
[snip]
> Now I want to log the entire output to a log file as well as display
> it on the screen.
>> time sudo echo 'hi mom' | tee | logger -f /var/log/hiMom
> 
> Only that doesn't work :-)  Time is only on the screen, not in the log
> file, and /var/log/hiMom is empty, regardless of the permissions on
> that file.
> 
> Can someone explain the redirection going on here in a way I can grok?
'time' writes output to stderr, use "time sudo echo 'hi mom' 2>&1"
And why "logger -f"? Just "tee /var/log/hiMom".

-- 
Eugene V. Lyubimkin aka JackYF

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: