How do I delete inactive accounts?

lehels

Well-Known Member
Jul 10, 2006
91
0
156
There are Many accounts and the section does not appear that such accounts are inactive

I need a script, preferably in PHP to do this task automatically
You could check this script: "chkcpaccts" at:
cplicensing dot net slash scripts.php

This should help you track down inactive domains and then erasing them.

Lehel,
 

pratapsingh

Active Member
Mar 20, 2009
39
0
56
You can run this script on your risk please verify the outputs before deleting the accounts.
=======================================
:>/root/backupfolders
:>/root/existing_acctuser
:>/root/inacctive_account

ls /backup/cpbackup/weekly | cut -d"/" -f1>> /root/backupfolders
ls /var/cpanel/users | cut -d"/" -f1 >> /root/existing_acctuser

for i in `cat /root/backupfolders`;
do
count=`grep -c $i /root/existing_acctuser`
if [ $count == 0 ]
then
echo "$i : $count is an inacctive account";
echo "checking the accounits $i under userdomains $count `grep $i /etc/userdomains`";
echo $i >> /root/inacctive_account
fi;
done

echo "!!!!!!!!!! WARNING !!!!!!!!!!!!!"
echo "Do you really want to delete the InAcctive Accounts then press y else any other Key?"
echo "!!!!!!!!!! WARNING !!!!!!!!!!!!!"
path="/backup/cpbackup/weekly"
if [ $1 == y ]
then
for i in `cat /root/inacctive_account`;
do
echo "Deleting inactive account $i backup from the server"
rm -rf $path/$i
done
fi;
======================================

Same thing you can repeat on daily and monthly.