Grep files older than 1 day


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep files older than 1 day
# 1  
Old 10-28-2013
Grep files older than 1 day

I thought that this would work for grep'ing files older than 1 day.
HTML Code:
ps -o etime,pid,user,args -e|awk '/^[0-9]+-/'|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.

HTML Code:
  d_prod 33757970 61999560   0   Oct 27      -  0:00 /usr/lib/lpd/piobe -d s /var/spool/qdaemon/t__byia 
  d_prod 33823732 64297016   0   Oct 27      -  0:00 /usr/lib/lpd/pio/etc/piohpnpf -x umhn-gw45e-ps1 -p 9100 
  d_prod 33954782        1   0   Oct 22      -  0:00 /usr/lib/lpd/pio/etc/piohpnpf -x iphb-4h16-ps1 -p 9100 
  d_prod 34020298 20388700   0   Oct 27      -  0:00 /usr/lib/lpd/pio/etc/piohpnpf -x umhs-5picu-ps3 -p 9100 
  d_prod 34216790        1   0   Oct 25      -  0:00 /usr/lib/lpd/pio/etc/piohpnpf -x 10.2.4.14 -p 9100 
  d_prod 34282318        1   0   Oct 19      -  0:01 /usr/lib/lpd/pio/etc/piohpnpf -x 10.2.4.14 -p 9100 
  d_prod 35789678        1   0   Oct 18      -  0:01 /usr/lib/lpd/pio/etc/piohpnpf -x 10.1.2.147 -p 9100 
  d_prod 36117352        1   0   Oct 14      -  0:01 /usr/lib/lpd/pio/etc/piohpnpf -x stt-t6s22-ps1 -p 9100 
  d_prod 36445134        1   0   Oct 13      -  0:01 /usr/lib/lpd/pio/etc/piohpnpf -x stt-3n12-ps1 -p 9100 
  d_prod 36576086 55054126   0   Oct 18      -  0:00 /usr/lib/lpd/pio/etc/pioout -A0 -B33431 -C14688 -F\14\15 
  d_prod 36772662 43260322   0   Oct 24      -  0:00 /usr/lib/lpd/pio/etc/pioout -A0 -B34448 -C14688 -F\14\15 
  d_prod 36969394        1   0   Oct 25      -  0:00 /usr/lib/lpd/pio/etc/piohpnpf -x umhs-6d04-ps1 -p 9100 
  d_prod 37166000        1   0   Oct 26      -  0:00 /usr/lib/lpd/pio/etc/piohpnpf -x umhs-7c02-ps1 -p 9100 
  d_prod 37296914        1   0   Oct 25      -  0:00 /usr/lib/lpd/piobe -d s /var/spool/qdaemon/t__gxUa 
Please advise.
# 2  
Old 10-28-2013
see
Code:
man find

find files older than 1 day then grep a string.
# 3  
Old 10-28-2013
Are you looking for files or for processes?
# 4  
Old 10-29-2013
Sorry!! I am looking for PID older than 1 day.
Please advise.
# 5  
Old 10-29-2013
Try this:
Code:
ps -o etime,pid,user,args -e | awk '$1 ~ /[0-9]+\-/'

# 6  
Old 10-29-2013
As I can't see "/usr/bin/ksh" in any of the lines matching "qdaemon" I'm not surprised your output is empty. Try without the last grep.
# 7  
Old 10-29-2013
Code:
# ps -o etime,pid,user,args -e | awk '$1 ~ /[0-9]+\-/' |grep pio
19-08:53:21 12517408   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x iphb-3h25-ps2 -p 9100 
12-19:37:39 24051782   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x 10.5.3.38 -p 9100 
 7-06:06:23 44630260   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x stt-t6s22-ps1 -p 9100 
14-20:19:45 11665916   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x 10.3.4.18 -p 9100 
 4-06:34:30 16908752   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x umhs-5picu-ps1 -p 9100 
 9-06:08:08 21561844   d_prod /usr/lib/lpd/piobe -d s /var/spool/qdaemon/t--g3aa 
 2-06:39:09 40436142   d_prod /usr/lib/lpd/pio/etc/pioout -A0 -B34448 -C14688 -F\14\15 
14-08:43:36 42598762   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x 10.5.3.38 -p 9100 
 6-06:31:22 44499334   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x umhn-10w52a-ps1 -p 9100 
10-06:32:53 55509354   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x umhn-10w52a-ps1 -p 9100 
 5-15:40:17 58982670   d_prod /usr/lib/lpd/pio/etc/pioout -A0 -B43588 -C14688 -F\14\15 
 9-06:35:59  6488798   d_prod /usr/lib/lpd/pio/etc/piohpnpf -x umhs-5picu-ps1 -p 9100

The date and time looks confusing. Is there a way to make human-readable?

Please advise.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

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

3. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 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. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

7. Shell Programming and Scripting

how to delete the older files other than the recently added 5 files

Number of files will get created in a folder automatically daily.. so i hav to delete the older files other than the recently added 5 files.. Could u help me through this..?? (5 Replies)
Discussion started by: shaal89
5 Replies

8. Shell Programming and Scripting

Find the number of files older than 1 day from a dir

Hello All, I need to write a script/command which can find out the number of .csv files residing in a directory older than 1 day. The output should come with datewise (means for each date how many files are there). I've this command, but this command gives the total number of files. It's... (10 Replies)
Discussion started by: NARESH1302
10 Replies

9. Shell Programming and Scripting

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 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... (4 Replies)
Discussion started by: reddybs
4 Replies

10. Shell Programming and Scripting

Deleting / finding files older than X days missess a day

Hi When trying to find and delete files which are, say, 1 day, the find command misses a day. Please refer the following example. xxxd$ find . -type f -ctime +1 -exec ls -ltr {} \; total 64 -rw-rw-r-- 1 oracle xxxd 81 Apr 30 11:25 ./ful_cfg_tmp_20080429_7.dat -rw-rw-r-- 1... (4 Replies)
Discussion started by: guruparan18
4 Replies
Login or Register to Ask a Question