The classic way to do this - in the Unix 7th Edition Bourne shell further - is:
{ ...body of script here... } | logrotate ...
If you also want to redirect errors, follow these steps:
{ ...body of script here... } 2>&1 | logrotate ...
The only drawback of this notation is the (often fairly wide) separation between the start of the redirect and its end. From this point of view, replacing the Bash process is probably better if you are sure that you will have Bash available on all relevant systems.
source share