Here is a short example of the problem
Short script that writes every 10 seconds test to its stdout
> cat write.sh
#!/bin/sh
while [ 1 ];do
echo test
sleep 10
done
And here is how we execute it, where we redirect the stdout to file named output.txt
./write.sh > output.txt
Now, the script should run "forever", but for meantime it fills up the output.txt
We are looking for a way to backup this output.txt
without to restart the script.
Moreover, we are looking for an implicit solution, so even the script won't be aware that the file was backed up.
Of course that once we remove this file (e.g. compress it) the process (script) lose the track of this file and stop writing.
Even if we backup the file (compress) and then return the file back using touch
the script no long able to reattach to this file.
For example:
mv test_file.txt test_file111.txt
rm test_file111.txt
> lsof | grep write
write.sh 2644 ronnyr 1w REG 253,1 36 106059124 /home/ronnyr/test_file111.txt (deleted)
> touch test_file111.txt
write.sh 2644 ronnyr 1w REG 253,1 36 106059124 /home/ronnyr/test_file111.txt (deleted)