Merge pull request #1761 from YunoHost/small-tools

Add basic-space-cleanup command
This commit is contained in:
Alexandre Aubin 2024-01-13 19:29:25 +01:00 committed by GitHub
commit 54ad8dd2cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -1739,6 +1739,10 @@ tools:
help: python command to execute
full: --command
### tools_basic_space_cleanup()
basic-space-cleanup:
action_help: Basic space cleanup (apt, journalctl, logs, ...)
### tools_shutdown()
shutdown:
action_help: Shutdown the server

View file

@ -623,6 +623,18 @@ def tools_shell(command=None):
shell = code.InteractiveConsole(vars)
shell.interact()
def tools_basic_space_cleanup():
"""
Basic space cleanup.
apt autoremove
apt autoclean
journalctl vacuum (leaves 50M of logs)
archived logs removal
"""
subprocess.run("apt autoremove && apt autoclean", shell=True)
subprocess.run("journalctl --vacuum-size=50M", shell=True)
subprocess.run("rm /var/log/*.gz && rm /var/log/*/*.gz && rm /var/log/*.? && rm /var/log/*/*.?", shell=True)
# ############################################ #
# #