The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

/var folder taking too much space

Discussion in 'General Discussion' started by V3King, Dec 24, 2016.

  1. V3King

    V3King Member

    Joined:
    Feb 12, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hello,

    I am having issues with my server because of storage running out and found that /var is taking almost 14GB. var/log is taking around 3GB and var/lib is taking around 6GB.

    Could someone please help me how to clean it up?

    Thanks in advance.
     
  2. SysSachin

    SysSachin Well-Known Member

    Joined:
    Aug 23, 2015
    Messages:
    542
    Likes Received:
    39
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,
    First you have to check which exact log file taking space.Also, check which file/directory taking space under /var/lib using the command "du -sch *"

    Please check and update here with file/directory name so that I can assist you.
     
  3. V3King

    V3King Member

    Joined:
    Feb 12, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hello,

    Thank you so much for the quick response.

    I used the command you provided and here is the output for both var/log and var/lib:

    Output of var/log:

    Code:
    4.0K    audit
    160K    background
    172K    bandwidth
    8.0K    boot.log
    775M    btmp
    760M    btmp-20161201
    298M    chkservd.log
    12K     ConsoleKit
    812K    cron
    8.9M    cron-20161127
    8.9M    cron-20161204
    9.4M    cron-20161211
    9.9M    cron-20161218
    744K    dcpumon
    24K     dmesg
    24K     dmesg.old
    192K    dracut.log
    30M     exim_mainlog
    3.6M    exim_mainlog-20161127.gz
    3.3M    exim_mainlog-20161204.gz
    3.2M    exim_mainlog-20161211.gz
    3.3M    exim_mainlog-20161218.gz
    0       exim_paniclog
    4.0K    exim_paniclog-20161127.gz
    4.0K    exim_paniclog-20161204.gz
    4.0K    exim_paniclog-20161211.gz
    4.0K    exim_paniclog-20161218.gz
    308K    exim_rejectlog
    12K     exim_rejectlog-20161127.gz
    8.0K    exim_rejectlog-20161204.gz
    20K     exim_rejectlog-20161211.gz
    16K     exim_rejectlog-20161218.gz
    12K     lastlog
    420K    maillog
    18M     maillog-20161127
    16M     maillog-20161204
    16M     maillog-20161211
    15M     maillog-20161218
    5.1M    messages
    45M     messages-20161127
    49M     messages-20161204
    54M     messages-20161211
    64M     messages-20161218
    4.0K    ntpstats
    32K     prelink
    17M     sa
    11M     secure
    104M    secure-20161127
    114M    secure-20161204
    117M    secure-20161211
    143M    secure-20161218
    0       spooler
    0       spooler-20161127
    0       spooler-20161204
    0       spooler-20161211
    0       spooler-20161218
    4.2M    ul_load_stats
    28K     wtmp
    4.0K    xferlog.offset
    4.0K    xferlog.offsetftpsep
    4.0K    yum.log
    2.7G    total
    Output for var/lib:

    Code:
    20K     alternatives
    20K     authconfig
    8.0K    dbus
    8.0K    dhclient
    16K     dovecot
    4.0K    fprint
    4.0K    games
    4.0K    logrotate.status
    4.0K    misc
    24M     mlocate
    5.6G    mysql
    8.0K    ntp
    8.0K    plymouth
    28K     polkit-1
    12K     prelink
    4.0K    random-seed
    132K    readahead
    127M    rpm
    4.0K    rsyslog
    6.0M    spamassassin
    12K     stateless
    8.0K    udev
    18M     yum
    5.7G    total
     
  4. SysSachin

    SysSachin Well-Known Member

    Joined:
    Aug 23, 2015
    Messages:
    542
    Likes Received:
    39
    Trophy Points:
    28
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    Thanks for the update.

    It's seems that your mysql directory is using 5.6GB disk space on your server. You can remove old logs from your /var/log directory or you can move your mysql directory to other partition to make free space on /var partition

    If you want to move your mysql directory to any other partition then you can try with following steps.

    You can symlinking the old /var/lib/mysql to the new location

    Code:
    ln -s /home/var_mysql/mysql /var/lib/mysql
    
    First make a full mysqldump file
    Code:
    mysqldump --all-databases | gzip > /home/alldatabases.sql.gz
    
    Uncheck monitor in WHM > Service Manager for Mysql and save the area and stop mysql service.

    Make the directory for MySQL in /home, move it and symlink it:

    Code:
    mkdir /home/var_mysql
    mv /var/lib/mysql /home/var_mysql
    chown -R mysql:mysql /home/var_mysql/mysql
    ln -s /home/var_mysql/mysql /var/lib/mysql
    /etc/init.d/mysql start
    Re-check monitor in WHM > Service Manager for MySQL and save the area

    If anything goes wrong, you have the full mysqldump backup.
     
  5. V3King

    V3King Member

    Joined:
    Feb 12, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Can you please tell me how to clean up logs from var/log folder? It would be a great help.
     
  6. cPanelChrisI

    cPanelChrisI Technical Analyst II
    Staff Member

    Joined:
    Mar 24, 2014
    Messages:
    67
    Likes Received:
    11
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    Hello!

    cPanel logs are managed through the cPanel Log Rotation Configuration interface.

    cPanel Log Rotation Configuration - Documentation - cPanel Documentation

    You can also manage the size threshold for those under Tweak Settings.

    Tweak Settings - Stats and Logs - Documentation - cPanel Documentation

    For logs that aren't managed there, you will likely need to clear those out or remove them manually. This is also a good page for a reference on that as well.

    How to Clean Unmanaged Log Files - cPanel Knowledge Base - cPanel Documentation
     
    SysSachin likes this.
Loading...

Share This Page