mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-03-31 06:24:02 -04:00
Add internal hard drive disk cache cleaner scripts
This commit is contained in:
5
internal-hard-drive-disk-cache-cleaner/README.md
Normal file
5
internal-hard-drive-disk-cache-cleaner/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Run command
|
||||
|
||||
```bash
|
||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/internal-hard-drive-disk-cache-cleaner/run.sh)"
|
||||
```
|
||||
42
internal-hard-drive-disk-cache-cleaner/run.sh
Normal file
42
internal-hard-drive-disk-cache-cleaner/run.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
MESSAGE="Made by BigBearTechWorld"
|
||||
|
||||
# Function to print a decorative line
|
||||
print_decorative_line() {
|
||||
printf "%s\n" "------------------------------------------------------"
|
||||
}
|
||||
|
||||
# Print the introduction message with decorations
|
||||
echo
|
||||
print_decorative_line
|
||||
echo "Big Bear Internal Hard Drive Disk Cache Cleaner"
|
||||
print_decorative_line
|
||||
echo
|
||||
echo "$MESSAGE"
|
||||
echo
|
||||
print_decorative_line
|
||||
echo
|
||||
echo "If this is useful, please consider supporting my work at: https://ko-fi.com/bigbeartechworld"
|
||||
echo
|
||||
print_decorative_line
|
||||
|
||||
# Function to clear cache
|
||||
clear_cache() {
|
||||
echo -e "\e[1;32mSynchronizing disks...\e[0m"
|
||||
sync # Ensures that all pending changes are written to disk
|
||||
echo -e "\e[1;32mClearing page cache, dentries, and inodes...\e[0m"
|
||||
echo 3 > /proc/sys/vm/drop_caches # Clears the page cache, dentries, and inodes
|
||||
echo -e "\e[1;32mCache cleared successfully!\e[0m"
|
||||
}
|
||||
|
||||
# Ask the user for confirmation to proceed
|
||||
read -p "Do you wish to proceed with clearing the cache? (y/n) " answer
|
||||
case $answer in
|
||||
[Yy]* ) clear_cache;; # If yes, clear the cache
|
||||
[Nn]* ) echo "Operation aborted."; exit;; # If no, exit the script
|
||||
* ) echo "Please answer yes or no."; exit;; # If invalid response, exit
|
||||
esac
|
||||
|
||||
# End of script
|
||||
echo -e "\e[1;36mThank you for using the Big Bear Internal HDD Cache Cleaner. Goodbye!\e[0m"
|
||||
Reference in New Issue
Block a user