Last active
March 7, 2024 13:32
-
-
Save Buthrakaur/4eb1ad2bbe07e0dc39d1bee5df039f39 to your computer and use it in GitHub Desktop.
Revisions
-
Buthrakaur revised this gist
Mar 7, 2024 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,12 +30,18 @@ if [ "$FREE_SPACE_BYTES" -le "$THRESHOLD" ]; then echo "Cleaning up builds..." rm -rf "${GITLAB_RUNNER_HOME}/builds/*" # Clean up XCode cache rm -rf ~/Library/Developer/Xcode/DerivedData rm -rf ~/Library/Developer/Xcode/Archives/* # Add additional cleanup for other directories if needed # echo "Cleaning up additional directories..." # rm -rf "/path/to/other/directories/*" rm "${GITLAB_RUNNER_HOME}/gitlab-runner*.log" echo "Cleanup completed." else echo "Disk space is sufficient." -
Buthrakaur created this gist
Mar 7, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ #!/bin/bash # cron setup: # copy this script to ~ # chmod +x ~/gitlab_runner_cleanup.sh # crontab -e # # add following line: # 0 3 * * * ~/gitlab_runner_cleanup.sh >> ~/gitlab_runner_cleanup.log 2>&1 # Threshold for disk space, set to 5GB (5 * 1024 * 1024 * 1024 bytes) THRESHOLD=$((5*1024*1024*1024)) # Check free disk space on the root partition FREE_SPACE=$(df -k / | tail -n 1 | awk '{print $4}') # Convert KB to Bytes for comparison FREE_SPACE_BYTES=$(($FREE_SPACE * 1024)) if [ "$FREE_SPACE_BYTES" -le "$THRESHOLD" ]; then echo "Free space is below threshold, performing cleanup..." # Path to GitLab Runner's directories GITLAB_RUNNER_HOME=~ # Clean up cache echo "Cleaning up cache..." rm -rf "${GITLAB_RUNNER_HOME}/cache/*" # Clean up builds echo "Cleaning up builds..." rm -rf "${GITLAB_RUNNER_HOME}/builds/*" # Add additional cleanup for other directories if needed # echo "Cleaning up additional directories..." # rm -rf "/path/to/other/directories/*" rm "${GITLAB_RUNNER_HOME}/gitlab-runner*.log" echo "Cleanup completed." else echo "Disk space is sufficient." fi