一个简单的服务器释放空间脚本,放在root用户下赋给权限执行即可:
#!/bin/bash
# filename: sync.sh
freemem=$(cat /proc/meminfo | grep "MemFree" | awk '{print $2}')
if [ $freemem -le 10240000 ]
then
date >> /root/sync.log
free -m >> /root/sync.log
sync
sync
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
free -m >> /root/sync.log
fi