5

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.

2 Answers 2

4

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

watch "{ date +'...' ; ps u -C appName ; } >> logFile" 
0

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

You must log in to answer this question.