Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic deletion of old log files. #218

Open
Renegade89 opened this issue Jul 6, 2022 · 2 comments
Open

Automatic deletion of old log files. #218

Renegade89 opened this issue Jul 6, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@Renegade89
Copy link

As requested.

I cleaned up about 500MB's of log files today.
Is it possible to get this cleaned up f.e. every 7 days, 30 days or any custom interval automatically ? :)

@pedrofaria pedrofaria added the enhancement New feature or request label Jul 7, 2022
@kslen
Copy link

kslen commented Nov 24, 2023

Hey there, Renegade89.

You can add a cron job or scheduled task that deletes log files older than X days.

Example from my nightly routine on my Linux based server:

#!/bin/bash
echo "Deleting logs older than 2 days from /home/acc."
find /home/acc/ -type f -name "*.log" -mtime +2 -delete

I've put the lines above into somefile.sh, then made it executable with:

chmod +x somefile.sh

Then instructed cron that I want it to run every day at 5:30 AM.

To edit your users cron jobs, run:

crontab -e

Then add the following line, save and exit:

30 5 * * * your_username /path_to/somefile.sh > /dev/null 2>&1

You can omit "> /dev/null 2>&1" if you want the output to be logged.

@Renegade89
Copy link
Author

Renegade89 commented Dec 21, 2023

Bit of an old thread, but wanted to share my solution using Windows command line:

del /q /f /s "logs_*.log"

You can run this command from the accweb directory. It will search through all subdirectories, delete all files starting with "logs_" and extension .log.

It will therefore keep the server.log file in the log directory, but delete all the old stuff from the logs directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants