diff --git a/share/actionsmap.yml b/share/actionsmap.yml index 9382c70f3..a98653551 100644 --- a/share/actionsmap.yml +++ b/share/actionsmap.yml @@ -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 diff --git a/src/tools.py b/src/tools.py index 088400067..a2fd9d82e 100644 --- a/src/tools.py +++ b/src/tools.py @@ -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/*/*.?", + ] + ) # ############################################ # # #