LindaC
asked on
Removing a list of files from a rang of dates
I want to remove manualy a list of files that have the date earlier than September 2. Not including September 2, how can I do it.
Solaris 5.9.
Solaris 5.9.
ASKER
I executed your script, but there are still files from September 1 there:
What went wrong?
mapdev(oracle)#ls -lt
total 2593282
-rwxrwxrwx 1 oracle dba 213 Sep 2 15:07 test.sh
-rw-r----- 1 oracle dba 36882197 Sep 1 16:38 arch_mapdev0000006473.arc
.Z
-rw-r----- 1 oracle dba 36462688 Sep 1 16:36 arch_mapdev0000006472.arc
.Z
-rw-r----- 1 oracle dba 36642123 Sep 1 16:35 arch_mapdev0000006471.arc
.Z
-rw-r----- 1 oracle dba 35212602 Sep 1 16:32 arch_mapdev0000006470.arc
.Z
-rw-r----- 1 oracle dba 38314167 Sep 1 15:58 arch_mapdev0000006469.arc
.Z
-rw-r----- 1 oracle dba 38463725 Sep 1 15:55 arch_mapdev0000006468.arc
.Z
-rw-r----- 1 oracle dba 37801815 Sep 1 15:53 arch_mapdev0000006467.arc
.Z
-rw-r----- 1 oracle dba 38153479 Sep 1 15:51 arch_mapdev0000006466.arc
.Z
-rw-r----- 1 oracle dba 37899471 Sep 1 15:49 arch_mapdev0000006465.arc
.Z
-rw-r----- 1 oracle dba 36393595 Sep 1 15:38 arch_mapdev0000006464.arc
.Z
-rw-r----- 1 oracle dba 34954212 Sep 1 15:36 arch_mapdev0000006463.arc
.Z
-rw-r----- 1 oracle dba 37545823 Sep 1 15:35 arch_mapdev0000006462.arc
.Z
-rw-r----- 1 oracle dba 37551945 Sep 1 15:33 arch_mapdev0000006461.arc
.Z
-rw-r----- 1 oracle dba 37121976 Sep 1 15:31 arch_mapdev0000006460.arc
.Z
-rw-r----- 1 oracle dba 36156569 Sep 1 15:29 arch_mapdev0000006459.arc
.Z
-rw-r----- 1 oracle dba 34651479 Sep 1 15:28 arch_mapdev0000006458.arc
.Z
-rw-r----- 1 oracle dba 33893293 Sep 1 15:23 arch_mapdev0000006457.arc
.Z
-rw-r----- 1 oracle dba 39852001 Sep 1 15:05 arch_mapdev0000006456.arc
.Z
-rw-r----- 1 oracle dba 39812589 Sep 1 15:03 arch_mapdev0000006455.arc
.Z
-rw-r----- 1 oracle dba 38642300 Sep 1 15:00 arch_mapdev0000006454.arc
.Z
-rw-r----- 1 oracle dba 39425691 Sep 1 14:58 arch_mapdev0000006453.arc
.Z
-rw-r----- 1 oracle dba 40122795 Sep 1 14:56 arch_mapdev0000006452.arc
.Z
-rw-r----- 1 oracle dba 40330079 Sep 1 14:54 arch_mapdev0000006451.arc
.Z
-rw-r----- 1 oracle dba 40228699 Sep 1 14:52 arch_mapdev0000006450.arc
.Z
-rw-r----- 1 oracle dba 40713307 Sep 1 14:47 arch_mapdev0000006449.arc
.Z
-rw-r----- 1 oracle dba 40478345 Sep 1 14:45 arch_mapdev0000006448.arc
.Z
What went wrong?
mapdev(oracle)#ls -lt
total 2593282
-rwxrwxrwx 1 oracle dba 213 Sep 2 15:07 test.sh
-rw-r----- 1 oracle dba 36882197 Sep 1 16:38 arch_mapdev0000006473.arc
.Z
-rw-r----- 1 oracle dba 36462688 Sep 1 16:36 arch_mapdev0000006472.arc
.Z
-rw-r----- 1 oracle dba 36642123 Sep 1 16:35 arch_mapdev0000006471.arc
.Z
-rw-r----- 1 oracle dba 35212602 Sep 1 16:32 arch_mapdev0000006470.arc
.Z
-rw-r----- 1 oracle dba 38314167 Sep 1 15:58 arch_mapdev0000006469.arc
.Z
-rw-r----- 1 oracle dba 38463725 Sep 1 15:55 arch_mapdev0000006468.arc
.Z
-rw-r----- 1 oracle dba 37801815 Sep 1 15:53 arch_mapdev0000006467.arc
.Z
-rw-r----- 1 oracle dba 38153479 Sep 1 15:51 arch_mapdev0000006466.arc
.Z
-rw-r----- 1 oracle dba 37899471 Sep 1 15:49 arch_mapdev0000006465.arc
.Z
-rw-r----- 1 oracle dba 36393595 Sep 1 15:38 arch_mapdev0000006464.arc
.Z
-rw-r----- 1 oracle dba 34954212 Sep 1 15:36 arch_mapdev0000006463.arc
.Z
-rw-r----- 1 oracle dba 37545823 Sep 1 15:35 arch_mapdev0000006462.arc
.Z
-rw-r----- 1 oracle dba 37551945 Sep 1 15:33 arch_mapdev0000006461.arc
.Z
-rw-r----- 1 oracle dba 37121976 Sep 1 15:31 arch_mapdev0000006460.arc
.Z
-rw-r----- 1 oracle dba 36156569 Sep 1 15:29 arch_mapdev0000006459.arc
.Z
-rw-r----- 1 oracle dba 34651479 Sep 1 15:28 arch_mapdev0000006458.arc
.Z
-rw-r----- 1 oracle dba 33893293 Sep 1 15:23 arch_mapdev0000006457.arc
.Z
-rw-r----- 1 oracle dba 39852001 Sep 1 15:05 arch_mapdev0000006456.arc
.Z
-rw-r----- 1 oracle dba 39812589 Sep 1 15:03 arch_mapdev0000006455.arc
.Z
-rw-r----- 1 oracle dba 38642300 Sep 1 15:00 arch_mapdev0000006454.arc
.Z
-rw-r----- 1 oracle dba 39425691 Sep 1 14:58 arch_mapdev0000006453.arc
.Z
-rw-r----- 1 oracle dba 40122795 Sep 1 14:56 arch_mapdev0000006452.arc
.Z
-rw-r----- 1 oracle dba 40330079 Sep 1 14:54 arch_mapdev0000006451.arc
.Z
-rw-r----- 1 oracle dba 40228699 Sep 1 14:52 arch_mapdev0000006450.arc
.Z
-rw-r----- 1 oracle dba 40713307 Sep 1 14:47 arch_mapdev0000006449.arc
.Z
-rw-r----- 1 oracle dba 40478345 Sep 1 14:45 arch_mapdev0000006448.arc
.Z
mtime parameter returns true if file was modified one day ago.
What is your current time ?
Could you send output of date command ?
What is your current time ?
Could you send output of date command ?
ASKER
The output is this:
server name (oracle)# date
Fri Sep 3 11:02:14 AST 2004
server name (oracle)#
server name (oracle)# date
Fri Sep 3 11:02:14 AST 2004
server name (oracle)#
you also can try use -atime parameter instead of -mtime.
find /your/dir -atime +1 -exec rm {} \;
find /your/dir -atime +1 -exec rm {} \;
ASKER
What is atime ?
I just want to remove the files (trunc the time please) from more than one day ago.
Example, today is September 3, then I want to eliminate the files from Septemer 1.
I just want to remove the files (trunc the time please) from more than one day ago.
Example, today is September 3, then I want to eliminate the files from Septemer 1.
atime meaning access time. -atime +1 will return files that were accessed one day ago.
ASKER
There are still files from September 1 in the directory. this is the steps that I followed:
If there can be a way of ignoring the time, like truncate the time and then all files that are written on the directory from more than one day ago will be eliminated.
server(oracle)# pwd
/ORADATA/server/u04/arc
server (oracle)#find /ORADATA/server/u04/arc -atime +1 -exec rm {} \;
server(oracle)#
-rw-r----- 1 oracle dba 33597333 Sep 2 10:36 arch_mapdb0000004090.arc.
Z
-rw-r----- 1 oracle dba 22582961 Sep 2 09:15 arch_mapdb0000004089.arc.
Z
-rw-r----- 1 oracle dba 26427616 Sep 2 09:11 arch_mapdb0000004088.arc.
Z
-rw-r----- 1 oracle dba 36881715 Sep 2 09:06 arch_mapdb0000004087.arc.
Z
-rw-r----- 1 oracle dba 38440415 Sep 2 09:02 arch_mapdb0000004086.arc.
Z
-rw-r----- 1 oracle dba 40674947 Sep 2 08:59 arch_mapdb0000004085.arc.
Z
-rw-r----- 1 oracle dba 40390429 Sep 2 08:55 arch_mapdb0000004084.arc.
Z
-rw-r----- 1 oracle dba 41068423 Sep 2 08:52 arch_mapdb0000004083.arc.
Z
-rw-r----- 1 oracle dba 40943004 Sep 2 08:48 arch_mapdb0000004082.arc.
Z
-rw-r----- 1 oracle dba 40923801 Sep 2 08:45 arch_mapdb0000004081.arc.
Z
-rw-r----- 1 oracle dba 41024751 Sep 2 08:41 arch_mapdb0000004080.arc.
--More---rw-r----- 1 oracle dba 38741243 Sep 1 19:25 arch_mapdb0000004025.arc.
Z
-rw-r----- 1 oracle dba 38990345 Sep 1 19:16 arch_mapdb0000004024.arc.
Z
-rw-r----- 1 oracle dba 39377955 Sep 1 19:07 arch_mapdb0000004023.arc.
Z
-rw-r----- 1 oracle dba 36396799 Sep 1 18:57 arch_mapdb0000004022.arc.
Z
-rw-r----- 1 oracle dba 35038115 Sep 1 18:19 arch_mapdb0000004021.arc.
Z
-rw-r----- 1 oracle dba 35488418 Sep 1 17:42 arch_mapdb0000004020.arc.
Z
-rw-r----- 1 oracle dba 35406975 Sep 1 17:06 arch_mapdb0000004019.arc.
Z
-rw-r----- 1 oracle dba 30305043 Sep 1 16:29 arch_mapdb0000004018.arc.
Z
-rw-r----- 1 oracle dba 23757154 Sep 1 16:03 arch_mapdb0000004017.arc.
Z
-rw-r----- 1 oracle dba 14164813 Sep 1 12:32 arch_mapdb0000004016.arc.
Z
-rw-r----- 1 oracle dba 17041127 Sep 1 12:16 arch_mapdb0000004015.arc.
Z
-rw-r----- 1 oracle dba 28539745 Sep 1 12:15 arch_mapdb0000004014.arc.
--More--
If there can be a way of ignoring the time, like truncate the time and then all files that are written on the directory from more than one day ago will be eliminated.
server(oracle)# pwd
/ORADATA/server/u04/arc
server (oracle)#find /ORADATA/server/u04/arc -atime +1 -exec rm {} \;
server(oracle)#
-rw-r----- 1 oracle dba 33597333 Sep 2 10:36 arch_mapdb0000004090.arc.
Z
-rw-r----- 1 oracle dba 22582961 Sep 2 09:15 arch_mapdb0000004089.arc.
Z
-rw-r----- 1 oracle dba 26427616 Sep 2 09:11 arch_mapdb0000004088.arc.
Z
-rw-r----- 1 oracle dba 36881715 Sep 2 09:06 arch_mapdb0000004087.arc.
Z
-rw-r----- 1 oracle dba 38440415 Sep 2 09:02 arch_mapdb0000004086.arc.
Z
-rw-r----- 1 oracle dba 40674947 Sep 2 08:59 arch_mapdb0000004085.arc.
Z
-rw-r----- 1 oracle dba 40390429 Sep 2 08:55 arch_mapdb0000004084.arc.
Z
-rw-r----- 1 oracle dba 41068423 Sep 2 08:52 arch_mapdb0000004083.arc.
Z
-rw-r----- 1 oracle dba 40943004 Sep 2 08:48 arch_mapdb0000004082.arc.
Z
-rw-r----- 1 oracle dba 40923801 Sep 2 08:45 arch_mapdb0000004081.arc.
Z
-rw-r----- 1 oracle dba 41024751 Sep 2 08:41 arch_mapdb0000004080.arc.
--More---rw-r----- 1 oracle dba 38741243 Sep 1 19:25 arch_mapdb0000004025.arc.
Z
-rw-r----- 1 oracle dba 38990345 Sep 1 19:16 arch_mapdb0000004024.arc.
Z
-rw-r----- 1 oracle dba 39377955 Sep 1 19:07 arch_mapdb0000004023.arc.
Z
-rw-r----- 1 oracle dba 36396799 Sep 1 18:57 arch_mapdb0000004022.arc.
Z
-rw-r----- 1 oracle dba 35038115 Sep 1 18:19 arch_mapdb0000004021.arc.
Z
-rw-r----- 1 oracle dba 35488418 Sep 1 17:42 arch_mapdb0000004020.arc.
Z
-rw-r----- 1 oracle dba 35406975 Sep 1 17:06 arch_mapdb0000004019.arc.
Z
-rw-r----- 1 oracle dba 30305043 Sep 1 16:29 arch_mapdb0000004018.arc.
Z
-rw-r----- 1 oracle dba 23757154 Sep 1 16:03 arch_mapdb0000004017.arc.
Z
-rw-r----- 1 oracle dba 14164813 Sep 1 12:32 arch_mapdb0000004016.arc.
Z
-rw-r----- 1 oracle dba 17041127 Sep 1 12:16 arch_mapdb0000004015.arc.
Z
-rw-r----- 1 oracle dba 28539745 Sep 1 12:15 arch_mapdb0000004014.arc.
--More--
Do you have write permission to the directory with the user ID under which you are running the script?
Also, Solaris v5.9 implemented File Access Control Lists (FACLs). Do the persistent files have an ACL blocking you from deleting them?
ASKER
Yes, I have permission.
It seems that those files were updated on 2 September. Could you check it ?
ASKER
The script is functioning but not in the way I wanted.
The script is deleting the files but is taking the time to detect what is +1 day ago.
What I want is to delete the following: Example: today is September 3, then I want to delete all the files from Septtember 1. (ignoring the time)
In Oracle we have like trunc(sysdate) -1. In Unix I supposed you must have something like that?
The script is deleting the files but is taking the time to detect what is +1 day ago.
What I want is to delete the following: Example: today is September 3, then I want to delete all the files from Septtember 1. (ignoring the time)
In Oracle we have like trunc(sysdate) -1. In Unix I supposed you must have something like that?
remove + sign:
find /your/dir -mtime 1 -exec rm {} \;
+ sign means more that 1 day . But 1 September is exactly 1 day.
find /your/dir -mtime 1 -exec rm {} \;
+ sign means more that 1 day . But 1 September is exactly 1 day.
So for future your command should be
find . \( -mtime +n -o -mtime n \) -exec rm {} \;
where n should be replaced by number of days.
find . \( -mtime +n -o -mtime n \) -exec rm {} \;
where n should be replaced by number of days.
ASKER
SQL> select sysdate from dual;
SYSDATE
---------
03-SEP-04
SQL> select trunc(sysdate)-2 from dual;
TRUNC(SYS
---------
01-SEP-04 -------------------------- ---------- --------> September 1 is exactly 2 days before from today. Today is September 3
SQL>
SYSDATE
---------
03-SEP-04
SQL> select trunc(sysdate)-2 from dual;
TRUNC(SYS
---------
01-SEP-04 --------------------------
SQL>
ASKER
ramazanyich: Should the instruction find . --> be replaced with my directory ?
I do not want to erase files that are not mine in other subdirectories.
I do not want to erase files that are not mine in other subdirectories.
yes. '.' should be replaced by your directory
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For a given date, coment http:Q_21118175.html#11986630
is the better answer, it still work if you try it today.
Comment http:#11977875 only work, if you run the command on
Sep 4, 2004.
is the better answer, it still work if you try it today.
Comment http:#11977875 only work, if you run the command on
Sep 4, 2004.
It will remove all files that are modified more that 1 day ago