scripts/Linux/zabbix/cleanup_swap.sh

11 lines
276 B
Bash
Raw Normal View History

2023-08-22 15:56:34 +02:00
# clear swapusage
2023-08-22 09:16:23 +02:00
free_memory=`free -m | awk 'NR==2{print $7}'`
used_swap=`free -m | awk 'NR==3{print $3}'`
if [ $free_memory -gt $used_swap ]; then
sudo swapoff -a && sudo swapon -a
echo "Swap usage cleared!"
else
echo "Cannot clear swapusage, not enough memory!"
fi2