Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
    

2 Answers 2

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

 
discard

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.