Need to list 3 days old processes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to list 3 days old processes
# 15  
Old 08-03-2010
In the Find command you have mtine , ctime and atime ... I used the command long back , will try and tel u
# 16  
Old 08-03-2010
No,you can
Code:
stat /proc/pid

then you can find the STIME..Right?
we just need to check /proc/"[0-9]{1,}" folder
Then we can determine which process match...

---------- Post updated at 02:47 AM ---------- Previous update was at 02:40 AM ----------

Quote:
Originally Posted by girija
In the Find command you have mtine , ctime and atime ... I used the command long back , will try and tel u

Oh yes,we can use find them

just /proc/pid folder

---------- Post updated at 03:02 AM ---------- Previous update was at 02:47 AM ----------

Code:
for i in `find /proc/"^[0-9]\{1,\}" -maxdepth 1 -mindepth 1 -type d  -mtime +3 2>/dev/null | awk -F"/" '{print $3}' ; do ps -af -p $i ; done


Last edited by skles; 08-03-2010 at 04:41 AM.. Reason: typo
# 17  
Old 08-03-2010
find command to list the old processes...interesting! can u plz brief what exactly this command line is doing ?

Code:
for i in `find /proc/"^[0-9]\{1,\}" -maxdepth 1 -mindepth 1 -type d  -mtime +3 2>/dev/null | awk -F"/" '{print $3}' `; do ps -af -p $i ; done

# 18  
Old 08-03-2010
As far as I recall, HP-UX does not have a /proc filesystem.
# 19  
Old 08-03-2010
I don't why I can't run the command now ,maybe my shell changed...It doesn't matter..

So the command is not very good . we use a script.

First we find out the pid of process that has running in the system for more than 3 days.

Code:
find /proc -maxdepth 1 -mindepth 1 -type d -mtime +1 2>/dev/null| egrep -v /proc/[a-Z]  | awk -F"/" '{print $3}'  | tee /tmp/a

Second we can find which process with pid.
Code:
while read pid 
do
ps -p $pid -o stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm  # you can modify it to get what you want...
done < /tmp/a

FYI:
[root@unix proc]# ps -p 4062 -o stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
STAT EUID RUID TT TPGID SESS PGRP PPID PID %CPU COMMAND
Ss+ 0 0 tty2 4062 4062 4062 1 4062 0.0 mingetty

---------- Post updated at 09:11 AM ---------- Previous update was at 09:07 AM ----------

Quote:
Originally Posted by fpmurphy
As far as I recall, HP-UX does not have a /proc filesystem.
Oh no, so we can't use /proc ...

---------- Post updated at 09:28 AM ---------- Previous update was at 09:11 AM ----------

so can we use this option of ps below ?

bsdstart START time the command started. 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).

[root@unix proc]# ps -ea -o bsdstart,comm,pid | head
START COMMAND PID
18:41 init 1
18:41 migration/0 2
18:41 ksoftirqd/0 3
18:41 watchdog/0 4
18:41 events/0 5
18:41 khelper 6
18:41 kthread 7
18:41 kblockd/0 10
18:41 kacpid 11

So we need to determine the start-time;

HH -gt 70 ?

Then we can say the process is three days old.
# 20  
Old 08-03-2010
An earlier poster asked for ideas which would work with standard HP-UX commands.

We can get the elapsed time accurately from the alternative format of "ps".

For example:

Code:
UNIX95= ps -uusername -o etime,comm,pid

(Note the "comm" parameter must not be "command" in HP-UX).

However the "ELAPSED" column is fiddly to process because it is in three possible formats according to how long the elapsed time is.

<space><space><space>MM:SS

HH:MM:SS

D-HH:MM:SS
(Where D=days with no leading zeros)

The hyphen between days and hours is going to be handy because we can immediately eliminate processes which are less than a day old. Depending on the accuracy required for "3 days old" we could just use the days field or use it with the HH:MM:SS fields to create an elapsed time in any units.
# 21  
Old 08-05-2010
Thanks all for the feedback. I will try the options and will reply.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List files older than 10 days.

Hello all, I want to list the files older than 10 days. Currently am using find ./ -mtime +10 -exec ls -ltr {} \; command. But I want to execute the same command in 16 directories at a time and want an output asking to remove those file? Please help me to design the script. regards, Ajay (3 Replies)
Discussion started by: 02Ajay
3 Replies

2. Shell Programming and Scripting

How can i list files above 5 days old?

HI how can i list files above 5 days old i want to keep only last 5 days application logs Regards, Ben (3 Replies)
Discussion started by: bentech4u
3 Replies

3. HP-UX

listing processes older than n days

Hello; trying to find processes older than n days, mostly user shells Tried the following code on 11.31 box: in this case older than 5 days UNIX95= ps -ef -o user,pid,ppid,cpu,etime,stime | grep "-" | awk '{print $2}' | xargs ps -ef|grep -v '?' |\ awk '$5 !~ ""' | awk '($5 ~ "$(date "+%b")")... (6 Replies)
Discussion started by: delphys
6 Replies

4. AIX

etime - get processes running for more than 30 days

In AIX I am trying to get the processes ran by user declan using the following format: ps -aef -o user,pid,etime,args | grep declan Then I get a result similar to (for example): declan 103264 123-12:47:33 /applications/apache/1.3.39.0/bin/httpd -d /var/applications/apache/www1 ... (0 Replies)
Discussion started by: chipahoys
0 Replies

5. Shell Programming and Scripting

List the files which are older than 7 days

Hi Frnds, I have to list the files which are older than 7 days in the given directory. it should consider only the files and should not show subdirectories. Thanks, Raja (3 Replies)
Discussion started by: smr_rashmy
3 Replies

6. Solaris

List of files last modified 30/60/90 days

Hi, I want to find the list of all the files under a directory (including it's subdirectories) last modified 30 days, 60 days, 90 days..also I want to find out the rate at which the disk space is growing. Please help. (3 Replies)
Discussion started by: b.paramanatti
3 Replies

7. Shell Programming and Scripting

Need to kill processes that are older than 3 days

Hi, I need a .ksh script that lists all the process that are currently running and older than 3 days. once the process list is available i need to mail the list and then kill those processes. Quick response is highly appreciated :b: Thanks in Advance!!! Sri (3 Replies)
Discussion started by: Sriranga
3 Replies

8. Programming

how to get list of processes

Hi, How can I get a list of all the running processes, in C? (13 Replies)
Discussion started by: yaron
13 Replies

9. Shell Programming and Scripting

List directory 7 days older

Say folder archive/ contains many folder each created on a day. this folder may contain files. i want to write a script to delete all the folder inside archive/ which are 7 days older. i used the below script for the reason. find archive -mtime +7 -type d -exec rm -r {} \; pls suggest me if... (3 Replies)
Discussion started by: krishnarao
3 Replies

10. UNIX for Dummies Questions & Answers

list last 10 days modified files

All, Is there is anyother single command that will handle ls -lrt | tail -10 Please let me know Thanks, Arun. (1 Reply)
Discussion started by: arunkumar_mca
1 Replies
Login or Register to Ask a Question