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 84f3b8e15..c3a9b679c 100644 --- a/src/tools.py +++ b/src/tools.py @@ -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) # ############################################ # # #