时间:2021年08月17日 | 作者 : liuhui | 分类 : Linux | 浏览: 3520次 | 评论 0 人
阿里云限量代金券 | 此广告位出租25元/月 |
博士有台VPS硬盘只有10GB,今天发现安装一个工具提示硬盘空间不足,于是想找出哪个文件占用了那么多空间,始终找不到。
询问群里大佬,教我先用这个命令
du -ahd 1 /
他说盲猜是因为log文件
然后再试试这个命令
du -ahd 1 /etc
root@cavps:~# du -ahd 1 /etc 12K /etc/ufw 4.0K /etc/issue 4.0K /etc/kernel-img.conf 4.0K /etc/rc4.d 48K /etc/security 8.0K /etc/docker 8.0K /etc/containerd 4.0K /etc/ld.so.conf 8.0K /etc/selinux 8.0K /etc/apparmor 20K /etc/ld.so.conf.d 8.0K /etc/python3.7 4.0K /etc/locale.alias 20K /etc/ppp 4.0K /etc/xattr.conf 8.0K /etc/calendar 4.0K /etc/rc1.d 4.0K /etc/hostname 24K /etc/mime.types 4.0K /etc/group- 4.0K /etc/gshadow 12K /etc/groff 4.0K /etc/inputrc 4.0K /etc/gshadow- 4.0K /etc/ucf.conf 8.0K /etc/python 8.0K /etc/python3 8.0K /etc/cron.monthly 8.0K /etc/init 12K /etc/login.defs 4.0K /etc/discover-modprobe.conf 4.0K /etc/magic.mime 12K /etc/locale.gen 72K /etc/initramfs-tools 4.0K /etc/libaudit.conf 4.0K /etc/modules 44K /etc/network 4.0K /etc/bash.bashrc 4.0K /etc/resolv.conf 4.0K /etc/hosts 4.0K /etc/nsswitch.conf 4.0K /etc/hosts.deny 0 /etc/localtime 4.0K /etc/deluser.conf 4.0K /etc/gai.conf 4.0K /etc/debian_version 12K /etc/cron.weekly 4.0K /etc/binfmt.d 4.0K /etc/screenrc 4.0K /etc/rpc 8.0K /etc/discover.conf.d 8.0K /etc/xdg 12K /etc/vim 4.0K /etc/shells 12K /etc/sysctl.d 4.0K /etc/fstab 88K /etc/systemd 8.0K /etc/hdparm.conf 84K /etc/pam.d 4.0K /etc/sysctl.conf 80K /etc/grub.d 4.0K /etc/rc3.d 4.0K /etc/rc2.d 8.0K /etc/wgetrc 8.0K /etc/tmpfiles.d 4.0K /etc/protocols 16K /etc/X11 608K /etc/ssh 4.0K /etc/adduser.conf 12K /etc/dbus-1 4.0K /etc/reportbug.conf 4.0K /etc/mailcap.order 0 /etc/os-release 4.0K /etc/motd 16K /etc/udev 4.0K /etc/machine-id 32K /etc/dhcp 8.0K /etc/python2.7 4.0K /etc/debconf.conf 16K /etc/skel 4.0K /etc/passwd 0 /etc/environment 8.0K /etc/ca-certificates.conf 4.0K /etc/profile 4.0K /etc/issue.net 4.0K /etc/bindresvport.blacklist 4.0K /etc/rc6.d 4.0K /etc/hosts.allow 4.0K /etc/mailcap 4.0K /etc/rc5.d 4.0K /etc/shadow 4.0K /etc/mke2fs.conf 4.0K /etc/passwd- 56K /etc/iproute2 4.0K /etc/bash_completion 4.0K /etc/crontab 0 /etc/.pwd.lock 12K /etc/apm 76K /etc/init.d 32K /etc/logrotate.d 4.0K /etc/shadow- 8.0K /etc/alternatives 28K /etc/dpkg 136K /etc/console-setup 132K /etc/apt 20K /etc/services 8.0K /etc/ca-certificates 4.0K /etc/rsyslog.d 4.0K /etc/networks 8.0K /etc/gss 4.0K /etc/rcS.d 660K /etc/ssl 8.0K /etc/profile.d 8.0K /etc/update-motd.d 0 /etc/mtab 4.0K /etc/magic 4.0K /etc/group 8.0K /etc/securetty 8.0K /etc/manpath.config 4.0K /etc/pam.conf 4.0K /etc/subuid 8.0K /etc/terminfo 576K /etc/apparmor.d 12K /etc/nanorc 0 /etc/rmt 80K /etc/default 4.0K /etc/timezone 8.0K /etc/cron.d 12K /etc/chrony 4.0K /etc/subgid 4.0K /etc/modprobe.d 4.0K /etc/logrotate.conf 4.0K /etc/rc0.d 12K /etc/NetworkManager 32K /etc/cron.daily 16K /etc/perl 20K /etc/logcheck 8.0K /etc/ldap 8.0K /etc/ca-certificates.conf.dpkg-old 4.0K /etc/dictionaries-common 12K /etc/emacs 8.0K /etc/cron.hourly 8.0K /etc/bash_completion.d 4.0K /etc/rsyslog.conf 6.2G /etc/nginx 4.0K /etc/host.conf 4.0K /etc/opt 44K /etc/kernel 4.0K /etc/rc.local 4.0K /etc/modules-load.d 20K /etc/ld.so.cache 6.2G /etc
通过我们人工检索,我们发现占用最大的目录是nginx文件,足足用了6.2GB!
进入nginx检查出是log文件,大神猜的果然没错!
root@cavps:/etc/nginx# du -sh * 4.0K client_body_temp 80K conf 4.0K fastcgi_temp 12K html 6.2G logs 4.0K proxy_temp 11M sbin 4.0K scgi_temp 4.0K uwsgi_temp root@cavps:/etc/nginx# cd logs root@cavps:/etc/nginx/logs# du -sh * 6.1G access.log 106M error.log 4.0K nginx.pid
但是请不要直接删除access.log
清空日志内容就可以了,命令如下:
echo "" > access.log
通过这种方法,磁盘空间可以马上释放,而不需要重启服务器。这种方法经常用于在线清理Apache、Tomacat、Nginx等WEB服务器产生的日志文件。
推荐您阅读更多有关于“”的文章
Powered By Z-Blogphp
分享:
支付宝
微信