Skip to content

Instantly share code, notes, and snippets.

@llccing
Created April 17, 2024 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llccing/b1171812ec61c0a274d8ed26b7f317ef to your computer and use it in GitHub Desktop.
Save llccing/b1171812ec61c0a274d8ed26b7f317ef to your computer and use it in GitHub Desktop.
#!/bin/bash
# 确保脚本以 root 权限运行
if [ "$EUID" -ne 0 ]
then echo "请以 root 权限运行"
exit
fi
# 同步磁盘数据,确保所有缓存数据写入磁盘
echo "正在同步磁盘数据..."
sync
# 清理缓存
echo "正在清理所有缓存..."
echo 3 > /proc/sys/vm/drop_caches
# 显示完成消息
echo "缓存清理完成!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment