Terminating cPanel accounts that has been suspended for X days

postcd

Well-Known Member
Oct 22, 2010
721
21
68
Hello,

i found good looking bash scripts that can help terminate cpanel accounts that has been suspended for more than X days.

http://linuxhostingsupport.net/blog/script-to-teminate-suspended-accounts-on-a-cpanel-server
http://www.mickgenie.com/terminate-cpanel-account-that-suspended-for-more-than-2-months/

I wanted to ask if following command is safe and will list only accounts that has been inactive/suspended for more than 60 days?

find /var/cpanel/suspended/ -mtime +60

If it is safe to terminate each account found by that command. Im OK with terminating accounts that are non-temporarily suspended for more than 60 days.

Thank you
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello,

I wouldn't terminate accounts based on the output of that command because the product is not designed with the idea that users might terminate accounts based on the files within that directory. A new version of cPanel could theoretically change the way that directory works and result in the termination of accounts you don't want terminated. Instead, a third-party solution such as WHMCS is recommended.

Thank you.
 

postcd

Well-Known Member
Oct 22, 2010
721
21
68
Im having WHMCS but can't find any bundled function or free addon for doing this bulk termination.
If /var/cpanel/suspended/ do not contain sure fire key for deleting old suspended accounts, which files on WHM server can give me data on which i can base termination of long suspended accounts? I can create simple bash script, just need to know where are data on which i can base it.

If WHM suspended accounts page contains checkboxes and select all option, i could be sorting according to suspension date and buk delete.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
You can post to the WHMCS support forums for additional clarification, however I believe this is the feature:

http://docs.whmcs.com/Automation_Settings#Enable_Termination

As far as values to check, you could look for these entries in the /var/cpanel/users/$username files:

Code:
SUSPENDED=1
SUSPENDTIME=
However, you may want to configure your custom script to email you a notification and force you to manually approve any such terminations. Again, you are using values to terminate accounts (removing all of it's data) based on values we don't intend for use with this purpose. Thus, you are risking data loss if you configure your script incorrectly or something changes in the product.

Thank you.
 

postcd

Well-Known Member
Oct 22, 2010
721
21
68
SUSPENDTIME seems to be there even for active (not suspended) cpanels
but suspended cpanels seems to always have SUSPENDED=1 line (bandwidth suspended does not have this line)
Here is the bash script that is using Michael's method/advice to discover old suspended cpanels and terminate them.
 
  • Like
Reactions: Patrick Heinz