Skip to content

add logfile cleanup utility#1872

Open
peterjanssens wants to merge 1 commit intocollectiveaccess:dev/2.0from
libis:feat/clean_stale_logs_utility
Open

add logfile cleanup utility#1872
peterjanssens wants to merge 1 commit intocollectiveaccess:dev/2.0from
libis:feat/clean_stale_logs_utility

Conversation

@peterjanssens
Copy link
Contributor

We would like to propose a logfile cleanup utility. This allows for periodic cleanup (manual or cron) of the application logfiles (log_....txt).

Exisiting GarbageCollection utility does not handle logs, and the current logger doesn't auto delete old files.
Size limitations causes some logfiles to spill over to the root /tmp, so that directory was added

dry run is the default mode for a standard expiration of 100 days.
days can be set to any integer >0.
mode can be set to delete for actual deletion and verbosity can be set to verbose/quiet/silent for the sake of cron logging.

@collectiveaccess
Copy link
Owner

It would be better if this did not rely upon shell_exec to function.

@peterjanssens
Copy link
Contributor Author

peterjanssens commented Mar 4, 2026

what alternative(s) would you suggest ?
@Unlink($path); as in unused_media ??

@peterjanssens
Copy link
Contributor Author

I swapped the shell_exec for unlink (with glob for filematching)

@collectiveaccess
Copy link
Owner

You could also use caGetDirectoryContentsAsList(), which is a helper defined in app/helpers/utilityHelpers.php

@peterjanssens
Copy link
Contributor Author

that helper has no pattern matching option, so you would still have to loop 'all' files no ?
and combine both (logdir, /tmp)

@collectiveaccess
Copy link
Owner

Yes, you'd have to loop through the files. That's going to happen one way or another. Your choice if you want to leave it as-is. We use glob in other places. Nothing wrong with it.

@peterjanssens
Copy link
Contributor Author

I'm ok with this version.

@peterjanssens peterjanssens force-pushed the feat/clean_stale_logs_utility branch from 10da325 to 7bb5e87 Compare March 5, 2026 09:33
@peterjanssens
Copy link
Contributor Author

that was not the proper way to handle the default (unpassed) parameters, fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants