Sponsored Content
Top Forums Shell Programming and Scripting Trying to filter user procs older than n days Post 302591127 by delphys on Wednesday 18th of January 2012 03:09:32 PM
Old 01-18-2012
Trying to filter user procs older than n days

Hello;

Trying to filter user procs older than n days from todays date.

The data I have to work with:
Code:
UNIX95= ps -ef -o user,pid,ppid,cpu,etime,stime | grep "-" | grep -v ^root |more
daemon    2048     1  0 47-01:55:24  Dec  2
dslgrai   4352  4351  0 6-00:13:00  Jan 12
sfmdb     2425  2421  0 47-01:55:19  Dec  2
sfmdb     2421     1  0 47-01:55:20  Dec  2
sfmdb     2426  2425  0 47-01:55:19  Dec  2
dslsw    14394     1  0 47-00:43:53  Dec  2
sfmdb     2702  2421  0 47-01:54:52  Dec  2
progress 10460     1 19 3-12:41:48  Jan 15
sfmdb     2648  2421  0 47-01:54:58  Dec  2
cimsrvr   2623  2622 39 47-01:55:08  Dec  2
sfmdb     2707  2421  0 47-01:54:52  Dec  2
dslhhan  16698 14680  0 11-21:45:11  Jan  6
progress  2682     1 43 3-12:35:57  Jan 15
sfmdb     3646  2421  0 47-01:53:39  Dec  2
hpsmh     3229  3224  0 47-01:53:59  Dec  2
sfmdb     3394  2421  0 47-01:53:52  Dec  2
sfmdb     2765  2421  0 47-01:54:48  Dec  2
dslslin  26129 26127  0 5-01:23:15  Jan 13
dslsw     4688     1  0 47-01:51:35  Dec  2
sfmdb     3593  2421  0 47-01:53:39  Dec  2
progress 28833     1 19 3-12:44:36  Jan 15
progress 28750     1  1 3-12:44:49  Jan 15
sfmdb     3594  2421  0 47-01:53:39  Dec  2
lp       19045     1  0 45-03:30:04  Dec  4
progress  1982     1 58 3-12:28:21  Jan 15
dslaban   9307  9220  0 2-02:06:43  Jan 16
progress 28105     1 46 3-12:37:01  Jan 15
dslaban   8804  8786  0 2-02:06:55  Jan 16

The comman I am using:

Code:
D=$(echo $(date +%d) -1|bc)
UNIX95= ps -ef -o user,pid,ppid,cpu,etime,stime | grep "-" | grep -v ^root |\
awk -v i=$D '(($6 == "Jan") && ($7 < $i)) || ($6 =="Dec")'

Output I am getting:

Code:
daemon    2048     1  0 47-02:20:36  Dec  2
sfmdb     2425  2421  0 47-02:20:31  Dec  2
sfmdb     2421     1  0 47-02:20:32  Dec  2
sfmdb     2426  2425  0 47-02:20:31  Dec  2
dslsw    14394     1  0 47-01:09:05  Dec  2
sfmdb     2702  2421  0 47-02:20:04  Dec  2
sfmdb     2648  2421  0 47-02:20:10  Dec  2
cimsrvr   2623  2622  0 47-02:20:20  Dec  2
sfmdb     2707  2421  0 47-02:20:04  Dec  2
sfmdb     3646  2421  0 47-02:18:51  Dec  2
hpsmh     3229  3224  0 47-02:19:11  Dec  2
sfmdb     3394  2421  0 47-02:19:04  Dec  2
sfmdb     2765  2421  0 47-02:20:00  Dec  2
dslsw     4688     1  0 47-02:16:47  Dec  2
sfmdb     3593  2421  0 47-02:18:51  Dec  2
sfmdb     3594  2421  0 47-02:18:51  Dec  2
lp       19045     1  0 45-03:55:16  Dec  4
sfmdb     6416  2421  0 46-22:23:22  Dec  2
dslawes  15380     1  0 26-21:21:34  Dec 22
dslbsab  28896 28776  0 41-22:48:55  Dec  7
dslbsab  28230     1  0 41-22:49:16  Dec  7
dslawes  16119 15380  0 26-21:21:15  Dec 22

In other words, I am missing all procs started in January
having a bit of trouble seeing what I am missing here.

Thanks for all advice
 

10 More Discussions You Might Find Interesting

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

2. UNIX for Advanced & Expert Users

Delete user file(s) older then 'X' days ??

I want to delete any file in unix file system which is older then a week. Those files should not be unix system file..means it should be user created file. Any clue to this ?? ASAP. Thanks. (2 Replies)
Discussion started by: varungupta
2 Replies

3. Shell Programming and Scripting

delete file older than N days

Hi, All, I'd like to delete files older than 1 day. I thought the following command find /your_directory -mtime +1-exec rm -f {} \; will do the work, but not so, it seems like it won't delete files unless it is 2 days old or older. the files between 1 day and 2 days old does not... (7 Replies)
Discussion started by: ericaworld
7 Replies

4. Shell Programming and Scripting

Script for deleting 30 days older

Hi, I need a script to delete files that are 30 days older and also the file name should contain aa or ab or ac as substring... Regards, Dolly.... (3 Replies)
Discussion started by: moon_friend
3 Replies

5. Shell Programming and Scripting

delete files more than 15 days older

i have to delete files which are older than 15 days or more except the ones in the directory Current and also *.sh files i have found the command for files 15 days or more older find . -type f -mtime +15 -exec ls -ltr {} \; but how to implement the logic to avoid directory Current and also... (3 Replies)
Discussion started by: ali560045
3 Replies

6. Shell Programming and Scripting

How to find files older than 30 days

Dear Friends, I have two queries. 1) I want to see the list of folders which were created 29 days ago. 2) I want to see the folders in which last created file is older than 29 days. Can it be done? Thank you in advance Anushree (4 Replies)
Discussion started by: anushree.a
4 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. UNIX for Dummies Questions & Answers

Files older than 50 days

Hi All, OS :- HP-UX wm5qa B.11.23 U ia64 1119805695 unlimited-user license I need to search files older than 50 days. I've used following command in order to search desired files, I also discoverd, it's showing today's files as well. Do you have any clue with this ? wmqa1> find .... (4 Replies)
Discussion started by: alok.behria
4 Replies

9. UNIX for Dummies Questions & Answers

Size of files which are older than x days

Hi I want to find the total space used by the files which are older than x days find ./ -type f -mtime +x-days -name "G00*" -exec du {} \; | awk '{total+=$1}END{print "TOTAL" total}' Total prints as 17.20 MB ( total / 1024*2 ) But actual size of it will be around 18.5 GB... (1 Reply)
Discussion started by: rakeshkumar
1 Replies

10. 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
Gtk2::RecentFilter(3)					User Contributed Perl Documentation				     Gtk2::RecentFilter(3)

NAME
Gtk2::RecentFilter HIERARCHY
Glib::Object +----Glib::InitiallyUnowned +----Gtk2::Object +----Gtk2::RecentFilter METHODS
recentfilter = Gtk2::RecentFilter->new $filter->add_age ($days) o $days (integer) $filter->add_application ($application) o $application (string) $filter->add_custom ($needed, $func, $data=undef) o $needed (Gtk2::RecentFilterFlags) o $func (scalar) o $data (scalar) $filter->add_group ($group) o $group (string) $filter->add_mime_type ($mime_type) o $mime_type (string) $filter->add_pattern ($pattern) o $pattern (string) $filter->add_pixbuf_formats boolean = $filter->filter ($filter_info) o $filter_info (scalar) string = $filter->get_name $filter->set_name ($name) o $name (string) recentfilterflags = $filter->get_needed ENUMS AND FLAGS
flags Gtk2::RecentFilterFlags o 'uri' / 'GTK_RECENT_FILTER_URI' o 'display-name' / 'GTK_RECENT_FILTER_DISPLAY_NAME' o 'mime-type' / 'GTK_RECENT_FILTER_MIME_TYPE' o 'application' / 'GTK_RECENT_FILTER_APPLICATION' o 'group' / 'GTK_RECENT_FILTER_GROUP' o 'age' / 'GTK_RECENT_FILTER_AGE' SEE ALSO
Gtk2, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team. This software is licensed under the LGPL. See Gtk2 for a full notice. perl v5.12.1 2010-07-05 Gtk2::RecentFilter(3)
All times are GMT -4. The time now is 04:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy