1

I know I can output script output to a file using :

/path/to/script.sh >& path/to/output.log

The thing is, I'm making an infinite loop in Java that my shell will run, thus the output file will become extremely large.

Is there anyway using linux commands to break the output by max file size to split the logs or instead i have to change outputin Java instead to console to seperate files by max file size?

eric.itzhak
  • 15,752
  • 26
  • 89
  • 142
  • 1
    I think this question might help you: http://stackoverflow.com/questions/6708580/use-tee-or-equivalent-but-limit-max-file-size-or-rotate-to-new-file – devrobf Aug 14 '13 at 13:40

2 Answers2

2

There is something called multilog, try this:

/path/to/script.sh |[multilog][2] s2000 ./logdir

will run the script capturing stdout to your output.log and rotating it when it is bigger than 2000 bytes.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
1

Yes, use logrotate

logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.

Mali
  • 2,990
  • 18
  • 18