![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deleting the files comparing the creation dates | pssandeep | UNIX for Dummies Questions & Answers | 2 | 04-10-2008 07:54 AM |
| Archive script old files | kayarsenal | Shell Programming and Scripting | 1 | 08-24-2006 10:46 PM |
| Archive files | kayarsenal | Shell Programming and Scripting | 13 | 08-21-2006 08:01 AM |
| tar archive with .Z files | Kun2112 | UNIX for Dummies Questions & Answers | 3 | 08-05-2005 06:42 AM |
| Deleting files automatically, the condition in the month of creation | FabioALex | UNIX for Dummies Questions & Answers | 4 | 12-10-2001 05:14 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi, I would modify to delete the files after creating the tar archive.
How I can modify the following command: tar -cvvf logswitch.tar `find *.log* -mtime +5` It create a tar with files that are older than 5 days. Last edited by Minguccio75; 02-12-2007 at 07:24 AM. Reason: solution |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Try this:
Code:
tar -cvf logswitch.tar `find *.log* -mtime +5` && find *.log* -mtime +5 -exec rm {} \;
|
|
#3
|
|||
|
|||
|
Is there the possibility to erase the files using an option of the tar command?
|
|
#4
|
|||
|
|||
|
I found the solution:
tar -cvvf logswitch.tar `find *.log* -mtime $Days` --remove-files |
|
#5
|
||||
|
||||
|
Good, but It'll work with GNU tar only
|
|
#6
|
|||
|
|||
|
for those without gnu tar
save file list in variable or file.
FILES=$(find ...) or find ... > /tmp/$(USER).flist.$$ then you can remove the files after the tar, without running find twice, (which might be a heavy process or) its state may change between the first and second iteration, causing you to actually lose data. For example: if you run the command close to midnight. the first +5 will find files just older than 5 days and the second running after midnite will add files a day older. and even if you use it in the middle of the day, the timestamp of files can cause a miss the same way. |
|||
| Google The UNIX and Linux Forums |