Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a file called 'log.txt' that I would like to move to the logs folder on a nightly basis.

The problem is that I want to keep track of the files so I would actually need to move it to a log1.txt, log2.txt, log3.txt and so on.

Is there a unix command or a bash script way to do this?

G-Man

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

You want to look at a tool called logrotate. You probably already have this installed due to other tools using it for exactly this purpose. It involves you writing a small config file and it will deal with rotating your logfile and restarting any process that has the file open.

share|improve this answer
    
Awesome! Thanks! –  GeoffreyF67 Oct 19 '09 at 17:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.