How to dump standard output from bash?

I have a script running in the background that prints some output. I have redirected standard output to a file for log purposes. However, I don't want this file to grow forever, what would be a good rollover way without coding logic? (Or rollover depending on date or file size).

+2


source to share


3 answers


Output the output to something like multilog , it will handle the whole thing for you.

And an example:



script_that_produces_output.sh |multilog s2000 ./logdir

      

will run a stdout script on a file named ./logdir/current

, spinning it when it is over 2000 bytes.

+6


source


logrotate (8)



+1


source


As well as multilog, there is also a similar tool svlogd from runit . You may find that it is already packaged with your distribution, as daemontools (multilog) has only recently become publicly available.

0


source







All Articles