This is what I'm trying to achieve:
Is this possible? Because to truly run it in the background wouldn't we have to do the redirection before marking it as a background process? Or is there some technique to work around this?
You can redirect to a temporary file and then mv
that file to the required name e.g.
process > /tmp/process.log &
mv /tmp/process.log /tmp/$!.log
$!
is the pid of the previously backgrounded process. Note that the mv simply renames that file. It won't interrupt writing to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With