How to redirect the stdout and stderr in rolling file with Unix redirection How to redirect the stdout and stderr in rolling file with Unix redirection unix unix

How to redirect the stdout and stderr in rolling file with Unix redirection


Pipe the result to split like this:

java MyAppName | split -b500k - Console.log

This will create a new file every time you go over 500k. See the man-page for split for more details and options.


Or you can use rotatelogs

nohup java MyAppName 2>&1 | rotatelogs -l Console_%Y-%m-%d.log 86400 &

This will create a new file with today's date every day