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

S-a-t
S-a-t used Ask the Experts™
on
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!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017

Commented:
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 .......

Author

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!
Distinguished Expert 2017
Commented:
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

Author

Commented:
Thanks Arnold!

I will check it.

Author

Commented:
Thanks Arnold for answering the questions, I appreciate it.
My sincere apologies as I was late to reply to your comment.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial