Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic-space-cleanup command #1761

Merged
merged 2 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions share/actionsmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
)
tituspijean marked this conversation as resolved.
Show resolved Hide resolved
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/*/*.?",
]
)

# ############################################ #
# #
Expand Down