Listing processes that are a day older


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Listing processes that are a day older
# 1  
Old 06-01-2010
Listing processes that are a day older

Hi All,

I am trying to automate some stuff to make my 'to-do-things' easier. I am in need for help regarding this.

I have an output
Code:
root 17187  3465  0 23:00:00 ?        0:01 Process1    
root  4975  4974  0 May 12 ?        0:00 Process2    
root  4042 16713  0 Jan 30 pts/22   0:00 Process3
root 17187  3465  0 23:00:00 ?        0:01 Process4
.
.

I will have to get only the process list which are active more than a day. i.e. Processes that are started on 'May', 'Jun' from the above output.

Here is what i have got so far:

Code:
#!/bin/ksh
ps -ef  | grep string | awk '{print $4, $10}' >>$tmp_file
the tmp file should be modified in such a way that it should contain only processes that are active older than 1 day
Please help me out in this part
for i in `awk '{print $2 }' $tmp_file`
do
echo $i >>$tmp_file2
done
mailx -s subject address <$tmp_file2

Thanks,
Sai
# 2  
Old 06-01-2010
on Solaris10:
Code:
-> /usr/ucb/ps augxww |egrep "PID|$LOGNAME" |nawk '$9 !~ ":" {print $0;}'

or:
Code:
-> ps -ef    |egrep "PID|$LOGNAME" |nawk '$5 !~ ":" {print $0;}'

# 3  
Old 06-02-2010
Thank you very much for the reply..

Can you please brief in what the command does? Sorry for bothering..!
# 4  
Old 06-02-2010
Both methods (running on Solaris, hence the nawk...otherwise, use awk) do a ps listing of the current login's activity. It then evaluates the Start Time column from ps for a timestamp (as opposed to a date), by seeing if it has a ":" within it; if it does, then it's only been started in the last 24 hours. If it doesn't, then output the entire line.
# 5  
Old 06-03-2010
Thanks curleb... Your logic works fine and is really good.

here is the modified script<This looks really fantastic:-)Smilie>

Code:
#!/bin/ksh

ps -ef  | grep string | nawk '$5 !~ ":" {print $11;}' >>$tmp_file

mailx -s subject address <$tmp_file

Thanks,
Sai
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Listing files older than 30 days

Hi, Could someone help me that what the problem is in this code? #!/bin/sh FOLDER=/abc/datasource/checkstatus TIMESTAMP=$(date +%s) for filename in $(find $FOLDER -maxdepth 1 -type f -name "CHECK_STATUS*"); do f1=$($filename -Eo "{4}+") f2=$(date -d "$f1" +%s) if... (11 Replies)
Discussion started by: Home
11 Replies

2. Shell Programming and Scripting

Grep files older than 1 day

I thought that this would work for grep'ing files older than 1 day. ps -o etime,pid,user,args -e|awk '/^+-/'|sort -t- -n -k 1,1 |grep qdaemon |grep /usr/bin/ksh But, it is not grep'ing any of files (i.e. below) older than 1 day. d_prod 33757970 61999560 0 Oct 27 - 0:00... (8 Replies)
Discussion started by: Daniel Gate
8 Replies

3. Shell Programming and Scripting

Find processes older than 1 day

// AIX 6.1 I need to extract PIDs of ps -ef |grep /usr/lib/lpd/pio | awk '{print $2}' ps -ef |grep qdaemon |grep /usr/bin/ksh | awk '{print $2}' that are older than 1 day. I know find . -type f -mtime +1, but it doesn't work for PIDs. Please let me know how to get the PIDs older than... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

4. Shell Programming and Scripting

Sftp - 1 day older files count

Need to write a shell script on AIX box which will connect to different servers using SFTP and get the file count of only 1 day older files. (purging list) How to achieve this? On local server we can use: find <path> -type f -mtime +1 But how to do it in case of SFTP? Please advise. Thanks... (9 Replies)
Discussion started by: vegasluxor
9 Replies

5. Shell Programming and Scripting

How archive the older than 30 day files to another unix server

I need to archive the older than 30 day file to another uinx server.I have wrote the below uinx script. for LOOK_DIR in /TempFiles do for FILE in `find ${LOOK_DIR} -mtime -30 -exec ls {} \;` do echo ${FILE} >> file_list ## This file will have the list of files copied and... (12 Replies)
Discussion started by: murari83.ds
12 Replies

6. 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

7. UNIX for Dummies Questions & Answers

Problem listing processes

hi! i wrote this script(ubuntu os): clear echo "number of running processes" ps -ef | wc -lbut i can't get the number of my currently running processes... is there a way to see HOW MANY processes are running to my system? ---------- Post updated at 11:20 PM ---------- Previous update... (2 Replies)
Discussion started by: strawhatluffy
2 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Find files older than 5 days and remove tem after listing

need help with this ... Find files older than 5 days and remove tem after listing list "test" file older than 5 days and then remove them (1 Reply)
Discussion started by: ypatel6871
1 Replies

10. Shell Programming and Scripting

Listing files older than 2 months

A script or command to list files older than 2 months in a specified directory and remove it. (3 Replies)
Discussion started by: pbekal
3 Replies
Login or Register to Ask a Question

Featured Tech Videos