Avatar of S-a-t
S-a-t
 asked on

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!
Shell ScriptingLinuxScripting Languages

Avatar of undefined
Last Comment
S-a-t

8/22/2022 - Mon
arnold

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-t

ASKER
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!
ASKER CERTIFIED SOLUTION
arnold

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
S-a-t

ASKER
Thanks Arnold!

I will check it.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
S-a-t

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