The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-26-2007
logic0 logic0 is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 11
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
  #2 (permalink)  
Old 04-26-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
dt=$( date +%Y%M%d )
cd /tmp
while read file
do
    cp ${file} "${file}_${dt}"
    : > ${file}
done < log
  #3 (permalink)  
Old 04-26-2007
logic0 logic0 is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 11
lamme question

output of /tmp/log is like
./access.log
./logs/access.log

in command i see using

while read file

file is the /tmp/log ?
  #4 (permalink)  
Old 04-26-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by logic0
output of /tmp/log is like
./access.log
./logs/access.log

in command i see using

while read file

file is the /tmp/log ?
Replace dot by actual path
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
  #5 (permalink)  
Old 04-27-2007
logic0 logic0 is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 11
thanks anbu

thanks anbu.. it worked kool !!! cheers
  #6 (permalink)  
Old 04-30-2007
Birasing Birasing is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 1
question

dt=$( date +%Y%M%d )
while read file
do
cp ${file} "${file}_${dt}"
: > ${file} --I did not undestsand this line, what does this line
done < /tmp/logs

Can u explain, what does that line.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0