Add basic-space-cleanup command

This commit is contained in:
tituspijean 2024-01-07 22:14:27 +01:00
parent aab80f9ecc
commit b920b82f4e
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720
2 changed files with 34 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,36 @@ def tools_shell(command=None):
shell = code.InteractiveConsole(vars)
shell.interact()
def tools_basic_space_cleanup():
"""
Basic space cleanup.
apt autoremove
apt clean
archived logs removal
journalctl vacuum (leaves 50M of logs)
"""
subprocess.run(
[
"/bin/bash",
"-c",
"apt autoremove && apt autoclean",
]
)
subprocess.run(
[
"/bin/bash",
"-c",
"journalctl --vacuum-size=50M",
]
)
subprocess.run(
[
"/bin/bash",
"-c",
"rm /var/log/*.gz && rm /var/log/*/*.gz && rm /var/log/*.? && rm /var/log/*/*.?",
]
)
# ############################################ #
# #