![]() |
|
|
|
|
|||||||
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| copy files with date | isingh786 | HP-UX | 1 | 03-10-2006 01:04 PM |
| listing files that does not belong to current date | esh.mohan | UNIX for Dummies Questions & Answers | 3 | 02-20-2006 08:24 AM |
| listing files that do not belong to current date | esh.mohan | Shell Programming and Scripting | 1 | 02-20-2006 06:38 AM |
| how to find files less than the current date | mallikarjuna | UNIX for Dummies Questions & Answers | 4 | 01-20-2006 09:49 AM |
| copy and rename list of files | kinmak | UNIX for Dummies Questions & Answers | 7 | 02-27-2005 05:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
script to rename files with current date and copy it.
I have few webservers logs like access.log. which would be growing everyday.
what i do everyday is, take the backup of access.log as access.log_(currentdate) and nullify the access.log. So thought of writing a script... but stuck up in middle. My requirement: to take the backup and nullify the log after it reaches 500 mb 1) i am able to find the logs which are more than 500mb using this command find . -size +1000000 -exec ls -l {} \; > /tmp/logs 2) How do i pickup the files mentioned in /tmp/logs and take the backup with currentdate ? i need a command to backup (copy) with current date in same directory . Thanks logic0 |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
Code:
find <path_to_directory> -size +1000000 -exec ls -l {} \; > /tmp/logs
Code:
dt=$( date +%Y%M%d )
while read file
do
cp ${file} "${file}_${dt}"
: > ${file}
done < /tmp/logs
|
|
|||
|
Quote:
Code:
: > ${file}
|
|||
| Google UNIX.COM |
| Thread Tools | |
| Display Modes | |
|
|