PS -ef ??


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers PS -ef ??
# 1  
Old 12-28-2011
PS -ef ??

Smilie How do you list all processes started in the last 24 hours, using one command? This is for Linux
# 2  
Old 12-28-2011
You could try
Code:
ps -ef|grep ":..:"

This will get all lines matching the search and therefore any processes over 24Hr (which then show just a date for the start column) will be eliminated, unless there is some other reason to match them, i.e. the command string matches it.


I hope that this helps,


Robin
Liverpool/Blackburn
UK
# 3  
Old 12-28-2011
Thanks for your help. The only problem with that command is that it lists everything. I need a command that only lists processes started less than 24 hours ago. Do you have an idea how I would do that?

Last edited by paris123; 12-28-2011 at 11:48 AM.. Reason: Making correction
# 4  
Old 12-28-2011
Please post a sample of your "ps -ef" output which shows some processes which you want to see ... and some which you do not want to see.


Btw. The "grep" from rbatte1 works on my system.
# 5  
Old 12-28-2011
Quote:
Originally Posted by methyl
Btw. The "grep" from rbatte1 works on my system.
My flavour of ps (procps version 3.2.7) when run as ps -ef includes the total time that the process has used, so all output lines match the grep pattern.

Maybe:
Code:
ps -ef| egrep -v "Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec"

This depends on the version of ps shifting the date in place of the time and when it does that; it might not be precise. I note on my system, processes that were started less than 24 hours ago, show Dec27 (rolls at midnight?), so if you really need all processes started in the last 24 hours you might turn to something like this:

Code:
find /proc -mtime -1 -name exe  2>/dev/null|grep -v /task/|xargs ls -l|awk '
{split( $(NF-2), a, "/"); printf( "%-10s %7s %s %s %s %s\n", $3, a[3], $6, $7, $8, $NF); }'

This is a real hack, and probably won't work on every system (certainly needs the proc file system to be functional), but it does present every process that was started during the past 24 hours (using the time that you run this command pipeline) and not just since midnight which is what you'll get if you depend on filtering away things like Dec21.

---------- Post updated at 11:17 ---------- Previous update was at 11:15 ----------

A bit of a sample ps output from my environment:

Code:
spot:[/home/scooter]ps -ef|head -14
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Dec19 ?        00:00:06 init [5]  
root         2     0  0 Dec19 ?        00:00:00 [kthreadd]
root         3     2  0 Dec19 ?        00:00:11 [migration/0]
root         4     2  0 Dec19 ?        00:00:32 [ksoftirqd/0]
root         5     2  0 Dec19 ?        00:00:03 [migration/1]
root         6     2  0 Dec19 ?        00:00:16 [ksoftirqd/1]
root         7     2  0 Dec19 ?        00:00:53 [events/0]
root         8     2  0 Dec19 ?        00:00:32 [events/1]
root         9     2  0 Dec19 ?        00:00:00 [khelper]
root        10     2  0 Dec19 ?        00:00:00 [kintegrityd/0]
root        11     2  0 Dec19 ?        00:00:00 [kintegrityd/1]
root        12     2  0 Dec19 ?        00:00:00 [kblockd/0]
root        13     2  0 Dec19 ?        00:00:00 [kblockd/1]

# 6  
Old 12-28-2011
I don't want to see the date. I want just the time:

I want to just see:
Code:
07:53 ?        
07:53 ?       
08:51 ?        
08:51        
09:56      
09:56

I do not want to see:
Code:
Sep14
Oct13
Nov14
Dec05

I hope this helps!

Last edited by methyl; 12-28-2011 at 12:01 PM.. Reason: please use code tags
# 7  
Old 12-28-2011
Sorry but I do not believe that your "ps -ef" outputs dates in that format.
Please can you post some complete output lines (in code tags) taking special care to preserve any spacing.

Also it's time we knew what Operating System this is (blotting anything confidential like machine names and licence numbers):
Code:
# Operating System
uname -a
# Local settings
locale

 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question