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.

Able to terminate all accounts on server?

Discussion in 'General Discussion' started by kujoez, Jul 6, 2009.

  1. kujoez

    kujoez Member

    Joined:
    Jul 6, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    (SOLVED) Able to terminate all accounts on server?

    Hello, I currently have a server with over 1000 cPanel accounts on it and I wish to terminate all of them if possible. I tried using the Terminate Multiple Accounts option in WHM but haven't had any luck (it times out when I try to do more than 20 accounts or so) and it freezes my browser for a few minutes when clicking a handful of checkboxes. Is there an easy method to terminate all of the accounts without doing a fresh install?
     
    #1 kujoez, Jul 6, 2009
    Last edited: Jul 6, 2009
  2. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    From the shell, /scripts/killacct (username)

    The following could do some pretty nasty damage to a server
    but fortunately it must be executed as root to actually work
    but even still I am a little leary to post this below but since
    you asked, a small script to kill all accounts on the server
    at once and bypass the normal approval prompting:

    DO NOT EXECUTE THIS SCRIPT IF YOU DO NOT WANT TO
    WIPE THE ENTIRE SERVER CLEAN OF CPANEL ACCOUNTS AND
    YOU ARE ADVISED TO FIRST MAKE GOOD BACKUPS!


    Code:
    #!/bin/bash
    IFS="$"
    
    ls /var/cpanel/users | while read KUSER; do
      echo 'y' | /scripts/killacct ${KUSER}
    done
    
    Note that depending on the size of the files in the accounts and or activity logfiles,
    some accounts may take longer than others to delete and may not necessarily be
    hung but just regular processing deleting large accounts. That said, you stand a
    much better chance of things working from the shell than from the WHM interface
    when talking about such a large task as deleting 1000 accounts at once.
     
    #2 Spiral, Jul 6, 2009
    Last edited: Jul 6, 2009
  3. kujoez

    kujoez Member

    Joined:
    Jul 6, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for the reply! The server in question is my old server and all of the accounts were backed up before and after they were migrated to the new server. ;)
     
  4. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Then have fun! I've used the simple script above to wipe out quite a few
    old servers after migrations so that should take care of it for you.

    Basically just reads in the list of cpanel accounts from the system and
    executes a killacct against each login name ... simple as that!

    Nice thing is if for some odd reason the wipe process hangs anywhere,
    you'll pickup where you left off when you start the script again and
    don't have to redo any previous account deletions because once
    an account is deleted, they will no longer be read as a valid cpanel login
    the next time the script is executed.
     
    #4 Spiral, Jul 6, 2009
    Last edited: Jul 6, 2009
  5. kujoez

    kujoez Member

    Joined:
    Jul 6, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Very nice. I'm glad I executed it from my home server because this looks like it will take a while. :D
     
  6. kujoez

    kujoez Member

    Joined:
    Jul 6, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Wow! Took almost 6 hours! :eek:
     
Loading...

Share This Page