LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-26-2017, 08:34 PM   #1
utnubudnai
LQ Newbie
 
Registered: May 2008
Posts: 9

Rep: Reputation: 0
Question [logrotate] why the stderr cannot be redirected to stdout?


my command is this:
Code:
 logrotate  -v -f /opt/backup/logrotate.conf -s /opt/backup/logrotate.log 2>&1 >> /tmp/run.log
I intend to redirect all the outputs into the /tmp/run.log file, but I failed, I can see all the outputs within the console. below are the outputs.

Code:
reading config file /opt/backup/logrotate.conf

Handling 1 logs

rotating pattern: /opt/backup/config.tar  forced from command line (8 rotations)
empty log files are rotated, old logs are removed
considering log /opt/backup/config.tar
  log needs rotating
rotating log /opt/backup/config.tar, log->rotateCount is 8
dateext suffix '-20171127'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
destination /opt/backup/config.tar-20171127 already exists, skipping rotation
 
Old 11-26-2017, 10:27 PM   #2
GentleThotSeaMonkey
Member
 
Registered: Dec 2016
Posts: 338
Blog Entries: 4

Rep: Reputation: 128Reputation: 128
Try putting the 2>&1 *after* the >> /tmp/run.log
Idk why; let us know IF it works for you (it did for me)
 
Old 12-06-2017, 02:18 AM   #3
utnubudnai
LQ Newbie
 
Registered: May 2008
Posts: 9

Original Poster
Rep: Reputation: 0
Great, that works, but, how, why?

Quote:
Originally Posted by GentleThotSeaMonkey View Post
Try putting the 2>&1 *after* the >> /tmp/run.log
Idk why; let us know IF it works for you (it did for me)
 
Old 12-06-2017, 03:18 PM   #4
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,780

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
2>&1 directs stderr where stdin currently goes.
So you must first direct stdin to the file.
 
Old 12-07-2017, 08:01 PM   #5
utnubudnai
LQ Newbie
 
Registered: May 2008
Posts: 9

Original Poster
Rep: Reputation: 0
well, still dont understand, but I'll do my work:)

I'll google it, but the problem has been resolved now. I am closing it.
Quote:
Originally Posted by MadeInGermany View Post
2>&1 directs stderr where stdin currently goes.
So you must first direct stdin to the file.
 
  


Reply

Tags
logrotate, redirection, stderr


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
redirecting both stdout and stderr sigint-ninja Linux - Newbie 3 08-04-2017 09:10 AM
tar - write to stdout & create log files ( from stdout and stderr ) [solved] paziulek Linux - General 2 02-23-2014 12:26 PM
Help!!! How USB HID keyboard input redirected to STDOUT ellappan Linux - Software 2 06-04-2009 10:03 PM
stderr vs stdout sniffer_raghav Programming 2 09-05-2008 10:00 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 02:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration