简体   繁体   中英

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?

以下满足您的需求吗?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM