Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new to Linux and I am using command

watch "ps u -C appName >> logFile" 

to obtain the process info of appName and output into logFile.

However, it does not include the date time info.

I know that date command could return the date and time.

How could I insert the date command into the watch statement above so that the date would be included in the logFile for each watch command?

Thanks.

share|improve this question

migrated from stackoverflow.com Jun 1 '11 at 17:43

This question came from our site for professional and enthusiast programmers.

2 Answers 2

Since watch takes shell commands, give it a group command.

watch "{ date +'...' ; ps u -C appName ; } >> logFile" 
share|improve this answer

Something like watch "(date; ps u -C appName >> logFile)" should work

share|improve this answer

Your Answer

 
discard

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