Skip to content

Instantly share code, notes, and snippets.

@CanadianJeff
Created November 15, 2015 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CanadianJeff/f6403734e8400f94455b to your computer and use it in GitHub Desktop.
Save CanadianJeff/f6403734e8400f94455b to your computer and use it in GitHub Desktop.
Clean cPanel Apache Logs
#!/bin/bash
echo "Stopping HTTPD"
service httpd stop &>/dev/null
killall httpd &>/dev/null
rm -rf /tmp/sess_*
find /home/share -name 'error_log' -exec rm -rf {} \;
find /home/*/public_html -name 'error_log' -exec rm -rf {} \;
find /var/www/apache -name 'error_log' -exec rm -rf {} \;
#sed -i '/Execut/d' /usr/local/apache/logs/suphp_log
for ip in 192.168. 127.0.0.1 ::1; do
echo "Working On: $ip"
sed -i "/$ip/d" /usr/local/apache/logs/access_log
sed -i "/$ip/d" /usr/local/apache/logs/error_log
#sed -i "/$ip/d" /usr/local/apache/domlogs/*.me
sed -i "/$ip/d" /usr/local/apache/domlogs/*.com
sed -i "/$ip/d" /usr/local/apache/domlogs/*.ca
sed -i "/$ip/d" /usr/local/apache/domlogs/*.org
done
echo "Done"
sleep 3
echo "Starting HTTPD"
service httpd restart &>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment