Learn about Centmin Mod LEMP Stack today
Register Now

Server Cleanup Script

Discussion in 'Feature Requests & Suggestions' started by Jimmy, Nov 1, 2017.

  1. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    9:08 PM
    It would be great to have a server clean-up script.


    Some of my directories are getting large:

    5.2G /usr
    1.3G /svr-setup
    30G /var

    I have a file with some clean up tasks, but maybe there could be a simple script created to do a server cleanup for people. Something that could also be setup to run via cron for people who have VPSs with not a lot of space.

    Code:
    Getting size of biggest folders on server
    
    df -h
    du -h --max-depth=1 /
    du -h --max-depth=1 /home
    du -h --max-depth=1 /usr
    du -h --max-depth=1 /var
    
    Delete nginx backup contents
    
    # cd /usr/local/nginxbackup
    # rm -rf /usr/local/nginxbackup/nginxdirbackup/*
    # rm -rf /usr/local/nginxbackup/confbackup/*
    
    
    Do ccache clean command above
    
    # ccache -C
    
    # cd /svr-setup/
    # rm -rf /svr-setup/*
     
  2. eva2000

    eva2000 Administrator Staff Member

    55,209
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    11:08 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Might want to check out these threads which will shed some light :)
    FYI, each time you upgrade Nginx an auto backup of nginx conf files and ssl directories is generated. See http://centminmod.com/nginx.html#autobackup and http://centminmod.com/configfiles.html
    so if you want to disable nginx auto backups set in persistent config file /etc/centminmod/custom_config.inc
    Code (Text):
    NGINXBACKUP='n'
    

    As to clean ups they only mask the issue of disk usage - the goal is to properly size your server for disk usage allowance. Otherwise you will mistakenly think you have XX GB of disk free space for site usage, but then forget that that disk space gets used by centmin mod disk utilising features like ccache cache, nginx auto backups and any backup scripts you add yourself and general downloads required in /svr-setup for php and nginx upgrades etc.

    i.e. imagine your /svr-setup directory was 3GB and you had 2GB free disk space. Then you clear /svr-setup giving you 3+2 = 5 GB free disk space. Then you upload 4GB of site files to your vhost web root. Leaving 1GB free. Then you go to try and upgrade nginx and php which downloads to /svr-setup and run of out disk space preventing you upgrading nginx and php.
     
  3. Jimmy

    Jimmy Well-Known Member

    1,788
    390
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +990
    Local Time:
    9:08 PM
    I didn't know about the NGINXBACKUP='n' which I'll set in the custom_config.

    I understand about people making sure they have the right disk space. I only suggested it so that people could clean up some space they have with a single script.

    I have plenty of space, so that isn't an issue for me.
     
  4. eva2000

    eva2000 Administrator Staff Member

    55,209
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    11:08 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yeah it's tricky to deal with as cleaning it up just gives folks false sense of available disk space. The nginx auto backups are handy. For insight see Nginx - Developer Overview: How Nginx is installed on Centmin Mod LEMP stack

    for example it backs up all nginx ssl certs as some folks accidentally deleted their ssl certs or vhost and are left without a backup which you can restore from.