mtime unexpected behaviour


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers mtime unexpected behaviour
# 1  
Old 05-26-2012
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  
Old 05-26-2012
Try adding -xdev option to find command.
# 3  
Old 05-26-2012
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  
Old 05-26-2012
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  
Old 05-27-2012
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  
Old 05-27-2012
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  
Old 05-28-2012
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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

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

4. Shell Programming and Scripting

Find by name and mtime

Hi, I'm trying to find all files that have a .ksh and .p extension and that are 7 days old by using the below find command but it doesn't seem to as expected. It gives me random results.. Can someone point out what may be wrong? find . -name "*.ksh" -o -name "*.p" -mtime -7 (2 Replies)
Discussion started by: Jazmania
2 Replies

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

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

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

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

9. UNIX for Dummies Questions & Answers

mtime help!!!!!

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

10. UNIX for Dummies Questions & Answers

find . -mtime

...what am i doing wrong?? I need to find all files older than 30 days and delete but I can't get it to pull details for ANY + times. The file below has a time stamp which is older than 1 day, however if I try and select it using any of the -time flags it just doesn't see it. (the same thing... (1 Reply)
Discussion started by: topcat8
1 Replies
Login or Register to Ask a Question