Skip to content

Commit

Permalink
chore: update sh code
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-logan committed Aug 31, 2024
1 parent 7612dd4 commit cde76ba
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions usr/bin/clean_memory.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
#!/bin/bash
#autor: Gabriel Logan
if [ $(id -u) -ne 0 ]; then
echo Error
echo "You need run as root"
echo Shuting down

if [[ $(id -u) -ne 0 ]]; then
echo "Error: You need to run this script as root."
echo "Exiting..."
exit 1
fi
main(){
echo
echo Values before
free --mega
echo
echo Cleaning Memory...
echo

clean_memory() {
sudo sync
sudo echo 3 > /proc/sys/vm/drop_caches
sudo sync
Expand All @@ -25,12 +20,24 @@ main(){
sudo sync && sudo sysctl vm.drop_caches=3
sudo sync && sudo sysctl vm.drop_caches=2
sudo sync && sudo sysctl vm.drop_caches=1
}

main(){
echo
echo "Values before"
free --mega
echo
echo "Cleaning memory..."
echo

clean_memory

echo
echo Values now
echo "Values now"
echo
echo "Clean - Values = MegaByte"
free --mega
echo
echo by: Gabriel Logan
echo "by: Gabriel Logan"
}
main

0 comments on commit cde76ba

Please sign in to comment.