Memory cache flush cron if free Memory is less than X

vim /root/memory_cache_flush.sh

#!/bin/bash
freem=$(free -m|grep Mem|awk '{print $4}')
# change 1024 to other value, for e.g you want set limit to 2GB then change it to 2048
if [ "$freem" -lt 1024 ]
then
echo 1 > /proc/sys/vm/drop_caches
freenew=$(free -m|grep Mem|awk '{print $4}')
echo "Server had only $freem MB free RAM, After memory cache is flushed, free RAM is $freenew MB" | mail -s "Memory cache flushed on server server.the-d2.com IP_HERE" [email protected]
else
echo "Nothing to do"
fi

chmod 775 memory_cache_flush.sh
# Now add below line to ‘crontab -e
* * * * * bash /root/memory_cache_flush.sh

Install TEAM VIEWER 12 with Shell Script – Ubuntu

#!/bin/bash
# Use this script for Ubuntu only.
# By default this script will install 64bit Teamviewer


echo "============================================"
echo -e "\e[1;32m REMOVING PREVIOUS TEAMVIEWER IF ANY ............ \e[0m"
echo "============================================"
sudo apt-get remove teamviewer -y
sudo apt autoremove -y
sudo apt-get remove teamviewer:i386 -y
sudo dpkg -r teamviewer:i386
sudo dpkg --purge teamviewer
sudo dpkg --purge teamviewer:i386
sudo apt autoremove -y
rm -fr /tmp/teamviewer*
cd /tmp/ ; wget http://download.teamviewer.com/download/version_12x/teamviewer_amd64.deb
sudo dpkg -i /tmp/teamviewe*
sudo apt-get install libgcc1 -y
sudo apt-get -f install -y
sudo dpkg -l | grep -i teamviewer
if [[ $? != 0 ]]; then
echo "============================================"
echo -e "\e[1;31m TEAM VIEWER 12 INSTALLATION FAILED \e[0m"
echo "============================================"
else
echo "============================================"
echo -e "\e[1;32m TEAM VIEWER 12 INSTALLED SUCCESSFULLY \e[0m"
echo "============================================"
fi