On my CentOS I am trying to execute a php script that contains an endless loop to do some fancy stuff inside. It doesn't matter that an endless loop may not be an accurate solution for most cases, but it is for my testcase. If an error occures within this loop, the error is written to an output file (as is everything from stdout). This is what I do at the moment.
exec php testfile.php >> output.log 2>&1
This works as expected, but I want to know when stdout or stderr is writing something to the file, so I need some kind of timestamp on each line.
I already tried something like this, but if I do it as mentioned there, there is simply no output at all (I suspect it's because of not being a simple shell script).
Is it possible to redirect every echo
from testfile.php and every error from stderr to output.log with a timestamp on each line?