mtime unexpected behaviour


 
Thread Tools Search this Thread
# 1  
mtime unexpected behaviour

Hi All,
My requirement is to remove the more than 60 days files from Archive folder, so prepared this command.
Code:
for files in `find /abc/Archive/<file_name_25032012.dat> -type f -mtime 61|xargs ls -lrt`
do
  rm -f $files
done

I tested this command in both unix and informatica.
In unix if files are exists on this date then it's identifying files and removing else it's removing script files.
In informatica if file is exists on this date then identifying files and removing else it point to informatica library or ddl files which are installed in unix and removing them.
so anybody can help me the exact procedure to remove files.

Thanks,
Harris

Last edited by Scrutinizer; 05-26-2012 at 03:14 PM.. Reason: code tags
# 2  
Try adding -xdev option to find command.
# 3  
Hi, what happens if you execute this command?
Code:
find /abc/Archive/<file_name_25032012.dat> -type f -mtime 61|xargs ls -lrt

It cannot possibly deliver what you are looking for, since ls -lrt produces a 9 column (or thereabouts) output.

What OS is "informatica" BTW?
# 4  
Quote:
Originally Posted by harris
Hi All,
My requirement is to remove the more than 60 days files from Archive folder, so prepared this command.
Code:
for files in `find /abc/Archive/<file_name_25032012.dat> -type f -mtime 61|xargs ls -lrt`
do
  rm -f $files
done

I've never used informatica, but in unix I'd do yours as such:

Code:
find /abc/Archive/ -type f -mtime +61 -exec rm {} \;

find doesn't normally by default follow symlinks, but you could try explicitly telling it not to by adding -H at the start:

Code:
find -H /abc/Archive/ -type f -mtime +61 -exec rm {} \;

Should work and it's a little simpler, I believe. Tested on AIX and no problems there.
This User Gave Thanks to Vryali For This Post:
# 5  
Hi Vryali,
Thank you for your help, but i forgot to mention some information in my script. Actually i used for loop to maintain log. Like
Code:
for files in `find /abc/Archive/<file_name_25032012.dat> -type f -mtime 61|xargs ls -lrt`
echo "List of archive files are:"$files>>logdir/log.txt
do
rm -f $files
done

Can you help check with this way?

Thanks,
Harris

Last edited by Scrutinizer; 05-27-2012 at 05:01 PM.. Reason: code tags
# 6  
for loop
Code:
echo "List of Archive files:" > logdir/log.txt
for file in `find -H /abc/Archive/ -type f -mtime +61`; do
  echo "${file} >> logdir/log.txt
  rm -f ${file}
done

That what you're looking for?

Last edited by Vryali; 05-27-2012 at 04:48 PM.. Reason: Typo
# 7  
Hi Vryali,
i executed the find command individually like
Code:
find -H /abc/archive/filename_*.dat -type f -mtime +61

, it's showing
Code:
"find: path-list predicate-list".

Tried in google about this but didnt get, so could you please check this.
I am using -bash.

Thanks,
Harris

Last edited by Scrutinizer; 05-28-2012 at 09:31 AM.. Reason: code tags
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mtime or the equivalent for HP-UX

Is there a way that we can add the equivalent of "mtime +3" to HP-UX OS? AIX has mtime that can filter older than how many days, but it is hard to put it for HP-UX. I am trying to filter out the output with older than 3 days. Thank you so much!! lpstat -o |grep -v bytes |sort -nkb1 | ??... (8 Replies)
Discussion started by: danielshell
8 Replies

2. UNIX for Advanced & Expert Users

[BASH] Getopts/shift within a function, unexpected behaviour

Hello Gurus :) I'm "currently" (for the last ~2weeks) writing a script to build ffmpeg with some features from scratch. This said, there are quite a few features, libs, to be downloaded, compiled and installed, so figured, writing functions for some default tasks might help. Specialy since... (3 Replies)
Discussion started by: sea
3 Replies

3. UNIX for Dummies Questions & Answers

Unexpected Behaviour from grepping Text File

Hi! I recently downloaded a wordlist file called 2of12.txt, which is a wordlist of common words, part of the 12dicts package. I've been getting unexpected results from grepping it, such as getting no matches when clearly there ought to be, or returns that are simply wrong. Par exemple: egrep... (4 Replies)
Discussion started by: sudon't
4 Replies

4. AIX

Unexpected Behaviour with WPAR

Hello, We have a system running AIX 6.1.7.1. We have created a Workload Partition(wpar) on this system with wpar specific routing enabled. On wpar, we are running DNS (UDP/53) and syslog (UDP/514). en0: 1.1.1.1/255.255.255.0 NOT assigned to any wpar en1:... (0 Replies)
Discussion started by: 03sep2011
0 Replies

5. Red Hat

-mtime command

Hello, what this command do. find /oracle/u01/app/oracle/admin/rdz/udump/ -name "*.trc" -mtime +1 Thanks, Umair (1 Reply)
Discussion started by: umair
1 Replies

6. UNIX for Dummies Questions & Answers

(find) mtime vs. (unix) mtime

Hi I've made some test with perl script to learn more about mtime... So, my question is : Why the mtime from findfind /usr/local/sbin -ctime -1 -mtime -1 \( -name "*.log" -o -name "*.gz" \) -print are not the same as mtime from unix/linux in ls -ltr or in stat() function in perl : stat -... (2 Replies)
Discussion started by: hiddenshadow
2 Replies

7. Shell Programming and Scripting

mtime

Hi, I've some files of some past days and everyday some new files are also getting added to the same. Now how can i use mtime to get the files of the current date i.e if i want the files of 25th feb 2009 and if im finding the files on 25th 12:10 am then i should only get the files after... (4 Replies)
Discussion started by: ss_ss
4 Replies

8. UNIX for Dummies Questions & Answers

-mtime +30

Hello, Can someone help me to understand the following: find /test/rman/ -mtime +30 -exec rm '{}' \; What does -mtime +30 mean? Thanks! (1 Reply)
Discussion started by: Blue68
1 Replies

9. Shell Programming and Scripting

mtime

hi, :) consider the following statement find . -type f -mtime -1 -print here what is the use of -1 option. any help? cheers RRK (7 Replies)
Discussion started by: ravi raj kumar
7 Replies

10. UNIX for Dummies Questions & Answers

mtime help!!!!!

thank you for the help. (2 Replies)
Discussion started by: scooter17
2 Replies

Featured Tech Videos