I'm currently redirecting all my service's standard output (stdout and stderr) to a single file, by starting is as such:

java blablaargs &> service.out

However, that file grows quite large. Is it possible, without changing the service program itself (perhaps via some filter command), to split the output by day?

Note: "Use a logging framework in Java" is not the droi... answer I'm looking for, sometimes important output just goes to stdout, out of my control.


You should configure logrotate to do this for you - that's it's job.


Take a look at something like cronolog http://cronolog.org

It will do exactly what you ask for, splitting log files based on template, reading from STDIN.


I would suggest using syslog (for syslog-ng's filter and rotating capabilities for example), especially if you already use it in your system.

In order to catch stdout and stderr to syslog, you can pipe your program's output to logger, e.g. for example: (from https://blogs.oracle.com/chrisg/entry/redirecting_output_to_syslog)

my_script | logger -p local6.debug -t my_script 2>&1

see the man (1) logger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.