Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
SVCPID=$!

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.

share|improve this question

3 Answers 3

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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