Skip to content

Instantly share code, notes, and snippets.

@marsyang1
Last active May 5, 2017 03:48
Show Gist options
  • Save marsyang1/c8f8d290a882d4b83492607011e897b7 to your computer and use it in GitHub Desktop.
Save marsyang1/c8f8d290a882d4b83492607011e897b7 to your computer and use it in GitHub Desktop.
Linux clean cache
if [ -z "${projectPathName}" ]; then
echo "ERROR: projectPathName IS NULL , Failed to START. Please recheck the variables"
exit 1 # terminate and indicate error
fi
echo "restarting $projectPathName ......."
projectPath="/home/webapp/$projectPathName"
echo "projectPath = $projectPath"
sudo sh -c 'echo 1 >/proc/sys/vm/drop_caches'
sudo sh -c 'echo 2 >/proc/sys/vm/drop_caches'
echo $projectPath
echo $(ps aux | grep $projectPath/ | awk '{print $2}')
kill $(ps aux | grep $projectPath/ | awk '{print $2}')
echo "pause 3 second"
sleep 3s
cd $projectPath
var=$(pwd)
echo "The current working directory $var."
sh bin/shutdown.sh && sleep 8s && sh bin/startup.sh && tail -f logs/catalina.out
#!/bin/bash
# Note, we are using "echo 3", but it is not recommended in production instead use "echo 1"
# http://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/
sudo sh -c 'echo 1 >/proc/sys/vm/drop_caches'
sudo sh -c 'echo 2 >/proc/sys/vm/drop_caches'
sudo sh -c 'echo 3 >/proc/sys/vm/drop_caches'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment