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.
source
to share