user979344
user979344

Reputation: 892

how to get current timestamp when using ps in a bash script?

So I am writing a shell script that gets all the current processes running, and pipes them into grep to filter out the ones I need.

But I also need it to give me a timestamp Either when the PS occurs, or when the process was started, it doesnt matter, I just need A time. All the processes just take fractions of seconds.

My command is this:

ps -U USERNAME -o rss=MEM,comm=CMD,pid=PID

I tried going like this:

ps -U USERNAME -o rss=MEM,comm=CMD,pid=PID, start=START

but that just gives me a time like hh:mm:ss. I need something more precise than this. Timestamps are ideal.

Any ideas?

Upvotes: 1

Views: 3909

Answers (1)

moooeeeep
moooeeeep

Reputation: 32502

does the following satisfy your need?

date; ps -U USERNAME -o rss=MEM,comm=CMD,pid=PID

Upvotes: 3

Related Questions