Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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
share|improve this answer

Check out this book on the Linux Command Line a lot of good info.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.