I am testing the redirection of running a PHP program into a screen.
Script does this:
<?php
for( $i=1; $i<=1000; $i++ )
{
sleep(1);
echo $i;
echo "\n";
}
I am running the above with:
screen -d -m bash -c 'php forlog.php >> ~/forlog.log 2>&1'
Redirection works fine but when I attach to the screen I have no output(blank screen) .
Is there anyway to have the output redirected to both file and within the screen?
P.S: I don't want to use nohup. Also when not redirected, the output can be seen within the screen just fine.
You could use tee to append to the log file and write to STDOUT (of screen) at the same time.
screen -d -m bash -c 'php forlog.php 2>&1 | tee -a ~/forlog.log'
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