• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net

cPanel Inactive Accounts Remover -- THT Support Included!


New Member
cPanel Inactive Account Removers

I am contributing to FWS after few months. Hope this will be useful for free web hosting owners.

I thought I might distribute this cPanel Inactive Account Remover which I developed in order to obtain more room for active free web hosting users.

More information can be found in here: http://perfectz.info/blog/inactive-accounts-remover-for-cpanel-servers/


Make a backup of every account in the server in case it deletes active accounts by mistake.
Download the script.

Modify the config.php according to your settings. The config.php have the following variables which need to be changed.

    $ipaddress = ""; //Servers IP Address
    $host = "hostname.example.com"; //Hostname
    $whmuser = "root"; //Username which has permissions to grab and delete user accounts
    $whmkey = ""; //WHM Remote Access Key
    $db_host = "";
    $db_name = "";
    $db_user = "";
    $db_passwd = "";
    $date = 1330560000; //Date in Unix format
This $date variable is used to identify the new accounts in the server.
Some people just don't upload data or forward their domain right after they register with you. In that case it is a good practice to keep this to a date before 2 weeks or back. That's up to you. Remember to convert date to unix date format before you use it. Use http://www.onlineconversion.com/unix_time.htm
Eg: If you want to delete the inactive accounts created before 1st of May,2012, you will have the unix date as 1335830400.

Log into your server and upload all the files including config.php which you just modified.
*Remember not to upload the scripts to publicly accessible place. Upload it to somewhere else.

Make the scripts executable.
 chmod +x delete.php listaccts.php whm.php
Run whm.php and set output into a file.
php whm.php >> Output.html
The script itself has the functionality to fetch user account data from a cPanel server and delete inactive accounts automatically. This script uses JSON to fetch data and a point system to detect which accounts are to be deleted.

You can contribute in various ways. I will have my pleasure even though you don't. :)

Comments and feedback is highly appreciated.
Last edited:


New Member
What is conciderd as an active account and what isn't?
The script is solely based on a point system. It gives points for various statuses of the domain name and hosting account.
If the hosting account has no disk space used: 3 points
Domain shows an index: 2 points
Default web site page: 5 points
IP does not resolve: 5 points

And it deletes accounts which has 5 points or more and which is created after $date.


New Member
If someone do not use TheHostingTool(THT), you can comment the line,
in whm.php.


New Member
Will this also work on whmcs?
Yes, it would. You just need to add WHMCS's database settings into config.php and modify the following line in delete.php
$sql="DELETE FROM tht_users WHERE user='{$user}'";
Replace tht_users with the table name which contain your client's data and user with the field which contains his username.


Active Member
This is awesome, if only I had this when I was actually running a free web host, this would have come in handy!!!!