LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   [logrotate] why the stderr cannot be redirected to stdout? (https://www.linuxquestions.org/questions/linux-server-73/%5Blogrotate%5D-why-the-stderr-cannot-be-redirected-to-stdout-4175618436/)

utnubudnai 11-26-2017 08:34 PM

[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


GentleThotSeaMonkey 11-26-2017 10:27 PM

Try putting the 2>&1 *after* the >> /tmp/run.log
Idk why; let us know IF it works for you (it did for me)

utnubudnai 12-06-2017 02:18 AM

Great, that works, but, how, why?

Quote:

Originally Posted by GentleThotSeaMonkey (Post 5785640)
Try putting the 2>&1 *after* the >> /tmp/run.log
Idk why; let us know IF it works for you (it did for me)


MadeInGermany 12-06-2017 03:18 PM

2>&1 directs stderr where stdin currently goes.
So you must first direct stdin to the file.

utnubudnai 12-07-2017 08:01 PM

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 (Post 5789782)
2>&1 directs stderr where stdin currently goes.
So you must first direct stdin to the file.



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