top of page
Search

clear script

  • knowledgediary4min
  • Mar 30, 2020
  • 2 min read

#!/bin/bash rm -f ./cleanspace.sh bold=$(tput bold) normal=$(tput sgr0) TIMESTAMP=$(date +%d-%m-%Y-%H-%M) LOGFILE="/root/cleardisk-$TIMESTAMP.log" #FULLDISK="$(df -h | grep a1 | awk {'print $1'})" FULLDISK="$(df -h | sed -n 2p | awk {'print $1'})" FULLDISKRB="$(tune2fs -l $FULLDISK | grep "Reserved block count" | awk {'print $4'})" #DISTRO="$(cat /etc/redhat-release | awk {'print $3'} | cut -f1 -d'.')" #DISTRO7="$(cat /etc/redhat-release | awk {'print $4'} | cut -f1 -d'.')" #DISTROCL="$(cat /etc/redhat-release | awk {'print $4'} | cut -f1 -d'.')" DIST="$(cat /etc/redhat-release | awk -F'[^0-9]*' '$0=$2')" clear echo -e "Welcome to the Quick Disk Cleaner!" sleep 1 echo -e "\nClearing Orphaned virtfs mounts..." /scripts/clear_orphaned_virtfs_mounts --clearall sleep 0.5 echo -e "\n${bold}Cleaning YUM Caches... ${normal}" rm -rf /var/cache/yum/* yum clean all echo -e "\n${bold}Cleaning Server...${normal} (grab a coffee, this may take a while) \n" ( cd /root find /home/*/.trash/* -exec rm -rf {} \; find /home/* -name core.[0-9]* -exec rm -vf {} \; rm -rf *.sql rm -rf *.zip rm -rf *.gz rm -rf *.tgz cd /tmp && find . -type f -exec rm -f {} \; rm -rf cpanel.TMP.work* rm -rf clamav* rm -rf spamd* rm -rf r1soft-cki* #cd /usr/local/apache/logs && find . -type f -exec sh -c '>{}' \; #cd /usr/local/apache/domlogs && find . -type f -exec sh -c '>{}' \; rm -rf /home/*/tmp/Cpanel_* > /var/named/data/named.run > /var/lib/mysql/mysql-error.err > /usr/local/maldetect/logs/inotify_log > /usr/local/maldetect/tmp/.digest.monitor.alert rm -rf /usr/local/maldetect/sess/* rm -rf /home/cprestore/* rm -rf /var/log/munin/* #rm -rf /home/*/*.sql rm -rf /home/*/error_log rm -rf /home/*/public_html/error_log rm -rf /home/*/public_html/*/error_log rm -rf /home/*/public_html/*/*/error_log rm -rf /home/cpmove* rm -rf /var/log/*.2 rm -rf /var/log/*.3 rm -rf /var/log/*.4 service nginx restart rm -rf /var/log/nginx/*.log* rm -rf /var/log/nginx/microcache.log* rm -rf /var/log/nginx/vhost-error_log* > /usr/local/cpanel/logs/access_log > /usr/local/cpanel/logs/error_log > /usr/local/apache/logs/suexec_log > /usr/local/apache/logs/modsec_audit.log > /usr/local/apache/logs/modsec_debug_log > /var/log/utmp > /var/log/wtmp > /var/log/chkservd.log > /var/log/cpanel-install-thread0.log find /var/log/atop/ -mtime +2 -exec rm {} \; find /home/ -name "*.unison.tmp" > /root/unisontmp.log for u in `cat unisontmp.log`;do rm -rf $u;done # /usr/local/apache/logs/access_log # /usr/local/apache/logs/error_log #mysqladmin drop eximstats #mysqladmin create eximstats #mysql eximstats < /usr/local/cpanel/etc/eximstats_db.sql #find /home/*/tmp/awstats -type f -name 'awstats*.txt' -exec rm -f {} \; #find /home/*/tmp/webalizer -type f -name '*.png' -o -name '*.html' -exec rm -f {} \; ) >/dev/null 2>&1 2>/dev/null & pid=$! # Process Id of the previous running command spin='-\|/' i=0 while kill -0 $pid 2>/dev/null do i=$(( (i+1) %4 )) printf "\r${spin:$i:1}" sleep .1 done echo -e "\n" sleep 0.5 if [ "$FULLDISKRB" -eq "0" ]; then echo -e "${bold}Leaving the system reserved space at it's default $FULLDISKRB ${normal}\n" sleep 0.5 # tune2fs -m 0 $FULLDISK else echo -e "${bold}Setting the system reserved space back to $FULLDISKRB ${normal}" sleep 0.5 tune2fs -m 5 $FULLDISK fi # Kill inotify watchers sleep 0.5 echo -e "\nKilling Logging..." sleep 5 for i in `ps auxf | grep inotify | grep delete | awk {'print $2'}`;do kill -9 $i;done sleep 0.5 echo -e "\nRescanning... \n" sleep 0.5 echo -e "${bold}Current Disk Usage: ${normal}" sleep 0.5 df -h echo -e "\n${bold}Complete... ${normal}\n" sleep 0.5 #if [[ -s $LOGFILE ]] ; then # echo "This log is empty because this system took too long to setup the inotify file watchers, sorry." >> $LOGFILE #fi echo -e "Please check ${bold}$LOGFILE${normal} for details.\n"

 
 
 

Recent Posts

See All
innodb restore

Create a new folder: mkdir /var/lib/mysql2 From R1: Restore from the /var/lib/mysql folder: + The folder which is called the db name...

 
 
 
Scripts

#not wordpress site grep shop2vizag.com /var/log/messages | awk '{print $6}' | cut -d: -f1 |sort -n |uniq -c |sort -n #Domains using...

 
 
 
Wordpress basic scripts

Site URL and Home URL SELECT * from wp_options WHERE option_name = 'home' OR option_name = 'siteurl'; update wp_options set option_value...

 
 
 

Comments


  • White Facebook Icon
  • White Twitter Icon
  • White Instagram Icon
  • White YouTube Icon

© 2023 by Knowledge4mind. Proudly created with Wix.com

bottom of page