Sign up ×
Server Fault is a question and answer site for 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?


share|improve this question

1 Answer 1

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

Your Answer


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.