Disk usage check in detail

Discussions related with hosting control panels used, which include cPanel, Plesk, Directadmin etc..
Post Reply
Chester
Posts: 0
Joined: Thu Oct 20, 2016 11:40 am

Disk usage check in detail

Post by Chester »

Hello,

How to find detailed disk usage of a /directory in Linux server in command line?



Joan N
Posts: 0
Joined: Mon Mar 27, 2017 11:46 am

Re: Disk usage check in detail

Post by Joan N »

Hi,

You can use following command to check the disk usage of a directory in detail.

#du -sch /directory/*

It will show the disk usage of the files and sub directories under this directory.
--
Joan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree
Last edited by Joan N on Sun Jun 03, 2018 4:40 pm, edited 1 time in total.



Chester
Posts: 0
Joined: Thu Oct 20, 2016 11:40 am

Re: Disk usage check in detail

Post by Chester »

Hello Joan,

Thank you for the quick reply. I have tried to check the disk usage of the entire server using below command.

#du -sch /*

But I got stuck at /home directory. Since /home is mounted to different drive I already know its disk usage. So please let me know how to skip /home and get the disk usage of all other files and folders under / .



Joan N
Posts: 0
Joined: Mon Mar 27, 2017 11:46 am

Re: Disk usage check in detail

Post by Joan N »

Hello,

You can use following command to exclude a particular directory while using #du -sch

#du -sch /* --exclude=home

--
Joan N
Linux Support Engineer.
Nixtree Solutions
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php
Follow us on : https://twitter.com/nixtree



Chester
Posts: 0
Joined: Thu Oct 20, 2016 11:40 am

Re: Disk usage check in detail

Post by Chester »

Thank you, Joan.



Micheal
Posts: 0
Joined: Sat Sep 17, 2016 5:50 pm

Re: Disk usage check in detail

Post by Micheal »

Hi,

I am also facing some disk issues with my server installed with cPanel. This time I can see that my /tmp partition reached 100%. How can I resolve this? All the services are down at the moment.

root@my.hostingserver.com:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 30G 25G 3.2G 89% /
tmpfs 3.8G 3.8G 0 100% /tmp

But there is nothing in /tmp at all

root@my.hostingserver.com:~# ls -Sahl /tmp |more
total 10K
dr-xr-xr-x. 25 root root 4.0K Mar 16 04:29 ..
drwxrwxrwt. 3 root root 3.0K Mar 16 03:32 .
drwx------. 2 root root 1.0K Mar 16 04:28 mc-root



Aaron
Posts: 17
Joined: Mon Apr 11, 2016 8:59 am

Re: Disk usage check in detail

Post by Aaron »

Hello,

You should use lsof /tmp to see if there any currently opened file. If you delete a file, while a software still have a lock on it, you won't see it anymore, but it will still have hd space assigned to it. After checking 'lsof', stopping the relevant process should free the space.

Also you can do 'tmpwatch' to clear the tmp partition. To setup /tmp to auto clean using tmpwatch

open SSH to your server, if SSH will not connect due to disk space full in tmp, reboot your server in then try again.
Once connected run the following command

Code: Select all

yum install tmpwatch -y
once tmpwatch is installed run command

Code: Select all

/usr/sbin/tmpwatch -am 12 /tmp
this will delete all files over 12 hours old

next, we will configure your server to do this automatically.

from SSH type:

Code: Select all

 crontab -e
go to the very bottom, paste it and save the file. So you can avoid such downtime issues.

Code: Select all

0 4 * * * /usr/sbin/tmpwatch -am 12 /tmp


Aaron N
Linux Support Engineer.
Nixtree Solutions LLP
Managed Full Server Backups
https://www.nixtree.com/managed-backups.php

Follow us on : https://twitter.com/nixtree

Post Reply