forked from xiaolongzuo/personal-blog-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto_delete_message.sh
17 lines (14 loc) · 1.5 KB
/
auto_delete_message.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
if [ -z "$1" ] ; then
echo "password is empty."
exit 1
fi
PASSWORD=$1
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select visitor_ip from messages group by visitor_ip having count(*) > 10) a);"
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select visitor_ip from messages group by visitor_ip having count(*)>1 and count(distinct(message))=1) a);"
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select message,visitor_ip from messages group by message,visitor_ip having count(*)>1) a);"
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select visitor_ip from messages where message like '%<button%') a);"
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select visitor_ip from messages where message like '%<script%') a);"
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select visitor_ip from messages where message like '%<button>%') a);"
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select visitor_ip from messages where message like '%<input%') a);"
mysql -uroot -p$PASSWORD blog -e "delete from messages where visitor_ip in (select a.visitor_ip from (select visitor_ip from messages where message like '%<input%') a);"