backup log files of 60 days, keep recent 60 day's and remove older

Hi Experts,

I have a log file which gets appended every day by a program.
FTPerror.log
I want to keep backup of this log file for 60 days using shell script on Linux, the log file is only one and not by date.
Time stamp will get updated of log file when ever it gets updated.

How do I keep backup of this log file for 60 days?

Another log file is inside folder and everyday new log files get copied to this folder, how do I keep backup of this for 60 days using shell script on Linux?

Thanks in Advance!
S-a-tAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
depending on the activity if your FTP the file can consume a large amount of space to cover 60 days.

Translating the data into an easily accessible version I.e. Converting the log data into a searchable DB might simplify the reporting as well as managing the deletion I.e. Delete from table entries 60 days prior to current day.

Another option is to configure logrotate to rotate the log when it reaches a specific size 500MB then based on your current 60 day size, include the counter to keep 60 days, and compress to zip the rotated files this way you can reduce the consumed space. And the rotation of the logs will delete older log files.

Check whether the program needs to be sent a signal HUP, etc. to make sure it creates a new file after the rotation as well as reattached .......
S-a-tAuthor Commented:
Log rotation sounds good idea. are you aware of the configuration? I can try that.
Does log rotation needs to be run as root?
I am using RedHat Linux 6.

Thanks Arnold!
arnoldCommented:
Look at /etc/logrotate.d
You should have files here that define the file/files being rotated
/var/log/squid/access.log {
The parameters, options, and what needs to be done to notify the application that it needs to reattach following the move of the file.

Man logrotate

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
S-a-tAuthor Commented:
Thanks Arnold!

I will check it.
S-a-tAuthor Commented:
Thanks Arnold for answering the questions, I appreciate it.
My sincere apologies as I was late to reply to your comment.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.