Cockatrice/servatrice/scripts/linux/maint_inactiveaccounts
woogerboy21 44025c667e Script Cleanup
Added the ability to specify custom database name.
Added the ability to specify custom table prefix.
Created sub folders for operating systems.
2015-07-14 15:05:02 -04:00

9 lines
No EOL
669 B
Bash

#!/bin/bash
# SCHEDULE WITH CRONTAB BASED ON TIME PERIOD UNACTIVE ACCOUNT SHOULD BE REMOVED. UPDATE INTERVAL DATE TO BE NUMBER OF DAYS OLD (OR OLDER) TO REMOVE.
DBNAME="servatrice" #set this to the database name used
TABLEPREFIX="cockatrice" #set this to the prefix used for the table names with in the database
SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file
NUMBEROFDAYS=5 #set this to the number of days to search for
mysql --defaults-file=$SQLCONFFILE -h localhost -e "delete from ""$DBNAME"".""$TABLEPREFIX""_users where active = 0 AND registrationDate < DATE_SUB(now(), INTERVAL ""$NUMBEROFDAYS"" DAY);"