ps -ef |grep 24 hours


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ps -ef |grep 24 hours
# 1  
Old 11-01-2011
ps -ef |grep 24 hours

I need to grep PIDs older than 24 hours (1 day) or more.
HTML Code:
ps -ef |grep ???
Please advise.
# 2  
Old 11-01-2011
Code:
ps -ef | awk 'NR > 1 {split($7, a,":"); if ( a[1] > 24 ) print a[1]}'

$7 may not be your field record for the TIME value. Depending on your ps output you will need to change this.
This User Gave Thanks to maverick72 For This Post:
# 3  
Old 11-01-2011
PHP Code:
  d_prod 1499142 5034194   0 16:00:47      -  0:00 /usr/bin/ksh /usr/lib/lpd/pio/etc/piojetd hgb-6kc-ps3 9100 -dp /var/spool/qdaemon/thX3b7a
  d_prod 3555364 5034194   0 16
:01:08      -  0:00 /usr/bin/ksh /usr/lib/lpd/pio/etc/piojetd hgb-g5j34-ps1 9100 -d s /var/spool/qdaemon/tNPuiaa
  d_prod 5816482 5034194   0 16
:01:02      -  0:00 /usr/bin/ksh /usr/lib/lpd/pio/etc/piojetd 3fens-ps1 9100 -dp /var/spool/qdaemon/tiL3pUa
    root 5034194  385266   0   Oct 26      
-  4:39 /usr/sbin/qdaemon 
The date and time format is a bit tricky, and are not being picked correctly.

Please advise.
# 4  
Old 11-01-2011
Something like this?...
Code:
ps -ef | awk '{if(match($5,"(..):(..)")){print $0}}'

--ahamed

Last edited by ahamed101; 11-01-2011 at 12:39 PM..
This User Gave Thanks to ahamed101 For This Post:
# 5  
Old 11-01-2011
Code:
ps -ef | awk '$5 ~ /[[:alpha:]]+/ {print}'

(assuming you want all the older processes (that will have a date rather than a time) and not vice-versa.)
This User Gave Thanks to CarloM For This Post:
# 6  
Old 11-01-2011
Updated the post! I thought less than 24 hours...
Code:
ps -ef | awk '{if(!match($5,"(..):(..)")){print $0}}'

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 7  
Old 11-01-2011
From the 'ps' command man page:

If the process was started less than 24 hours ago, the output format is "HH:MM", else it is "mmm dd" (where mmm is the three letters of the month).

So grepping for that month and date combination should work:

ps -ef | grep '[A-Z][a-z][a-z][0-9][0-9]'

Hope this helps.
This User Gave Thanks to in2nix4life For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. Shell Programming and Scripting

Get the no of hours between days

Hi, i have a date 1- 2013101511 date2 -2013101812 need toget the no of hours between them,can any one tellme the logic. (6 Replies)
Discussion started by: sandeep karna
6 Replies

3. Shell Programming and Scripting

Need help looking for missing hours.

I have a file that should cover a days worth of stats, at the beginning of each 15 minute report I have a unique header that looks like the below example. The "0000" and "0015" will change in the header line to show which 15 Minute interval the report is covering and of course from day to day the... (7 Replies)
Discussion started by: fsanchez
7 Replies

4. AIX

cron off by 5 hours

stupid question im sure, but its frustrating My cron jobs are off by 5 hours. My system time is right but all of my cron jobs are running approximately 5 hours late. Any idea why? (4 Replies)
Discussion started by: mshilling
4 Replies

5. Shell Programming and Scripting

CurrentTime-4 hours

Hi, Good Afternoon! I am writing this script on "sh" and have Variables as below. #Time in hours ex: 09 JobTime=`echo $StartTime |awk '{print $2}'|cut -f1 -d':'` SystemHours=`date +%H` How can go 4 hours back for each variable in a day? Another Question? JobStat=`dsjob -report... (5 Replies)
Discussion started by: rajubollas
5 Replies

6. Homework & Coursework Questions

list of files modified 10 hours ago using grep

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Here is the question: Make a list of files in your home directory that were changed less that 10 hours ago,... (3 Replies)
Discussion started by: fight4love
3 Replies

7. What is on Your Mind?

How Many hours on Computer?

How many hours you spend on Computer in a day??? (10 Replies)
Discussion started by: malcomex999
10 Replies

8. Shell Programming and Scripting

how to list files between last 6 hours to 3 hours

Hi Frens, I want to list some files from a directory, which contains "DONE" in their name, i am receiving files every minute. In this i want to list all the files which are newer than 6 hours but older than 3 hours, of current time i dont want my list to contain the latest files which are ... (4 Replies)
Discussion started by: Prat007
4 Replies

9. Post Here to Contact Site Administrators and Moderators

Have we just had a rollback of a few hours?

Have we just had a rollback of a few hours? (1 Reply)
Discussion started by: porter
1 Replies

10. UNIX for Dummies Questions & Answers

delete files that are over 2 hours old

guys, I have a need for a script that will delete all files in a given directory that are over 2 hours old. I will set this up to run in cron. I'm having a little trouble coming up with the syntax that will identify these files. Is there a variation of the ls command that I can use to identify... (3 Replies)
Discussion started by: hedrict
3 Replies
Login or Register to Ask a Question