I'm running the command
php someFile.php 1>> stdout.txt 2>> stderr.txt
Is there a way I can record when the stderr is printed?
Excellent question, I didn't know how to pipe stderr but I found the answer here.
Then, when you've got your stderr piped, you can just replace every beginning of line (^) by the message you want. Here I called the date command to display the time.
php someFile.php 2>&1 >> stdout.txt | sed "s/^/`date +'Error received the %d:%m:%y at %H:%M:%S : '`/" >> stderr.txt
Check out this book on the Linux Command Line a lot of good info.
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
2 years ago