Question about "Disk Usage" Use = 93%

Discussion in 'General' started by onastvar, Sep 7, 2021.

  1. onastvar

    onastvar Member

    In my Monitor
    The state of your Hard-Disk space is ok [More...]

    Size = 157G
    Used = 144G
    Available = 12G
    Use = 93%
    Mounted /

    Any suggestions or guides how to check and delete what's not needed.

    Thanks in advance!
     
  2. brainsys

    brainsys Member

    If you have console or ssh access du -hdn is your friend (where n is an integer to show the depth of the enquiry - start with 1) and cd-ing to the directories of interest eg /var/www or /var/backup or just plain /var etc.

    I keep my disks below 85% ''cos a big backup can temporarily eat up the rest causing the server to freeze. Then it's difficult to unpick.
     
    onastvar likes this.
  3. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    the obvious stuff, most stuff in /tmp can go, you could probably get away with just trying to delete it all, anything still in use/open should block deletion.
    check /var/log and subfolders. you can delete old log files, they'll probably all be .tar.gz files. check none of them are excessively large. it they are, you'll probably want to check why before deleting them. you'll probably also want to keep them all if you've been experiencing problems recently.

    might also want to check /var/www/<sitenames>/tmp see if somethings not deleting session files etc. shouldn't be anything big, but there could be a *lot* of them.

    does the server have to remain up? or is some downtime acceptable?
    if your server's been up and running continuously for a long time, you'll probably find that all the different kernel versions it's downloaded can take up a significant amount of space. i'd suggest running an apt update and apt upgrade and then rebooting. that should boot up on the latest kernel it has.
    once you've logged back in 'uname -r' will show you the running kernel. eg 4.15.0-142-generic
    use 'dpkg --list | grep linux-image' to list all the others. eg:
    Code:
    rc  linux-image-4.15.0-130-generic         4.15.0-130.134                                                      amd64        Signed kernel image generic
    rc  linux-image-4.15.0-132-generic         4.15.0-132.136                                                      amd64        Signed kernel image generic
    rc  linux-image-4.15.0-135-generic         4.15.0-135.139                                                      amd64        Signed kernel image generic
    rc  linux-image-4.15.0-136-generic         4.15.0-136.140                                                      amd64        Signed kernel image generic
    rc  linux-image-4.15.0-137-generic         4.15.0-137.141                                                      amd64        Signed kernel image generic
    rc  linux-image-4.15.0-139-generic         4.15.0-139.143                                                      amd64        Signed kernel image generic
    rc  linux-image-4.15.0-140-generic         4.15.0-140.144                                                      amd64        Signed kernel image generic
    rc  linux-image-4.15.0-141-generic         4.15.0-141.145                                                      amd64        Signed kernel image generic
    ii  linux-image-4.15.0-142-generic         4.15.0-142.146                                                      amd64        Signed kernel image generic
    
    then remove the older kernels with:
    Code:
    apt purge linux-image-4.15.0-130-generic
    apt purge linux-image-4.15.0-132-generic
    .
    .
    apt purge linux-image-4.15.0-141-generic
    
     
  4. onastvar

    onastvar Member

    thanks @nhybgtvfr
    Server has been up for months, I don't remember last time i rebooted it.
    Do you know if I could delete other_vhosts_access.log 13GB file without causing any server issues?
    It's located here
    /var/log/apache2/other_vhosts_access.log
     
  5. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    you can, although i'm not sure if apache with auto create a new one if you restart apache, pretty sure it doesn't without a restart.
    you may want to check the file permissions/ownership before deleting it, then after deleting it:
    Code:
    touch /var/log/apache2/other_vhosts_access.log
    chmod 640 /var/log/apache2/other_vhosts_access.log
    chown root:adm /var/log/apache2/other_vhosts_access.log
    
    and restart apache.
    not on a webserver at the moment, pretty sure those are the right ownership / permissions. but just adjust them to match whatever your check shows.

    is that 13Gb all from today? or is does it cover quite a time period? you might want to look at the logrotate settings and get it to rotate daily, or at a fixed (smaller) size.
     
    Jesse Norell likes this.
  6. onastvar

    onastvar Member

    13GB log file has date stamp of today
    /var/log/apache2/other_vhosts_access.log

    (log file content has data from October 2020 in the 100 first lines, and last 100 lines are from today (September 2021)

    I found this post from 2013 (does it still apply in 2021?).
    Is /var/log/apache2/other_vhosts_access.log required?
    Any server implication if I disable it per post:
    https://www.howtoforge.com/community/threads/how-to-desactivate-other_vhosts_access-log.60402/
    If I recreate the file size could grow again.
     
  7. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    from oct 2020?
    configure logrotation for it, new logfile daily, and keep the last 20 - 30 days worth, it'll compress the daily logs, and auto delete anything older. that should save you a lot of space now, and prevent it ever using as much (unless a daily log goes absolutely nuts)
    you can get away with not having the log file at all, but it's worth keeping it for troubleshooting if anything happens.
     
    onastvar likes this.
  8. onastvar

    onastvar Member

    @nhybgtvfr thank you
    I deleted 13GB file /var/log/apache2/other_vhosts_access.log
    Restarted apache, I guess apache re-created same file but size is now 1GB
    My server disk usage is now 83% (Thank You)
    For LogRotation i used default setting when I setup server using ISPConfig Perfect Server guides.
    If I go to ISPConfig control panel, under SITES > Webdomain > Options > Logfiles retention time is 10 (default)
    Would changing this to 3 or 5 generate less files etc?
    Also, are we able to control / set log file sizes?
     
    Last edited: Sep 10, 2021
  9. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    the setting for log retention in the control panel is for the client site vhosts under the /var/log/ispconfig/ subdirectory tree
    for the files in /var/log/apache2/ you want to look at the configs in /etc/logrotate.d/
    you should probably see a file in there for apache2, which should have a config to apply to all *.log files in /var/log/apache2.

    mine looks like the code below, which rotates those logs daily, compresses them, and keeps the most recent 14.
    you can set it to rotate at a max size, using the size or maxsize option
    i'd suggest you run 'man logrotate' and familiarize yourself with the config options before you make any substantial settings changes.

    Code:
    /var/log/apache2/*.log {
        daily
        missingok
        rotate 14
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        prerotate
            if [ -d /etc/logrotate.d/httpd-prerotate ]; then
                run-parts /etc/logrotate.d/httpd-prerotate
            fi
        endscript
        postrotate
            if pgrep -f ^/usr/sbin/apache2 > /dev/null; then
                invoke-rc.d apache2 reload
            fi
        endscript
    }
    
     
    onastvar likes this.
  10. onastvar

    onastvar Member

    My file is same as yours, I think, except couple of lines on the bottom in "postrotate" section

    /etc/logrotate.d/apache2

    Code:
    /var/log/apache2/*.log {
            daily
            missingok
            rotate 14
            compress
            delaycompress
            notifempty
            create 640 root adm
            sharedscripts
            postrotate
                    if /etc/init.d/apache2 status > /dev/null ; then \
                        /etc/init.d/apache2 reload > /dev/null; \
                    fi;
            endscript
            prerotate
                    if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                            run-parts /etc/logrotate.d/httpd-prerotate; \
                    fi; \
            endscript
    }
    
    I think the main issue was 13GB size of file
    /var/log/apache2/other_vhosts_access.log
     
    Last edited: Sep 10, 2021

Share This Page