The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Terminating cPanel accounts that has been suspended for X days

Discussion in 'General Discussion' started by postcd, Jul 14, 2016.

  1. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    620
    Likes Received:
    6
    Trophy Points:
    18
    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
     
    #1 postcd, Jul 14, 2016
    Last edited: Jul 14, 2016
  2. Patrick Heinz

    Patrick Heinz Active Member

    Joined:
    Mar 14, 2015
    Messages:
    26
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    Brasil
    cPanel Access Level:
    Root Administrator
    Twitter:
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  4. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    620
    Likes Received:
    6
    Trophy Points:
    18
    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.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  6. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    620
    Likes Received:
    6
    Trophy Points:
    18
    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.
     
    Patrick Heinz likes this.
Loading...

Share This Page