This will be a very dumb question to the gurus I'm guessing but here goes.
I am trying to keep track of the number of threads on my system and I need to add timestamp somewhere with each output.
Here is my current command to check number of threads :
watch -n1 'ps -eLo pid,cmd,nlwp | wc -l >> test.txt'
I would like the timestamp to be added on each line in test.txt
as the number of threads gets written
How do I get the output to look like 2020-12-14 07:08:10 5431
(where 5431 is the number of threads) ?
ts
or one of the many options involvingdate
from the dupe – muru Dec 14 '20 at 03:29watch -n 1 'printf "$(date +%F" "%T" ")" >> test.txt; ps -eLo pid,cmd,nlwp | wc -l >> test.txt'
– Terrance Dec 14 '20 at 03:29printf '%(%F %T)T %s\n' now "$(ps -eLo pid,cmd,nlwp | wc -l)"
, but I think like muruts
is a good choice – Dec 14 '20 at 17:04