![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| copy files with date | isingh786 | HP-UX | 1 | 03-10-2006 05:04 PM |
| listing files that does not belong to current date | esh.mohan | UNIX for Dummies Questions & Answers | 3 | 02-20-2006 12:24 PM |
| listing files that do not belong to current date | esh.mohan | Shell Programming and Scripting | 1 | 02-20-2006 10:38 AM |
| how to find files less than the current date | mallikarjuna | UNIX for Dummies Questions & Answers | 4 | 01-20-2006 01:49 PM |
| copy and rename list of files | kinmak | UNIX for Dummies Questions & Answers | 7 | 02-27-2005 09:23 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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 |
|
||||
|
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
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|