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.

Quickest way to delete 1000 accounts

Discussion in 'General Discussion' started by Hostiz.com, Feb 22, 2006.

  1. Hostiz.com

    Hostiz.com Registered

    Joined:
    Jan 18, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I run a free webhosting company and need to know whats the fastest way to remove 1000 accounts? Terminate multiple accounts from WHM always crashes my server if i do more than 5 at a time, and is way too time consuming. Anyone have any suggestions? Like maybe I can backup, then restore the server minus the accounts I want to remove? Im desperate for suggestions, thanks guys!
     
  2. Scott.Mc

    Scott.Mc Member

    Joined:
    Feb 22, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Are you going to terminate all the accounts on the server? or only a list of accounts?

    For a list you could do something like create delete.txt with each account on a new line then do something like delete.sh and have it contain

    Code:
    #!/bin/bash
    for i in `cat delete.txt`; do
    /scripts/killacct $i
    fi
    
    But I guess that would have the are you sure message, you could adjust the killacct script to disregard that message just for this termination.

    Something like cp /scripts/killacct /scripts/tmpkillacct and remove

    Code:
    if ( -t STDIN ) {
        print "Are you sure you want to do this [y/N]? \n";
        while($read = <STDIN>) {
            if ($read eq "n\n") { exit; }
            if ($read eq "N\n") { exit; }
            last if $read eq "Y\n";
            last if $read eq "y\n";
        }
    }
    
    from it, then adjust the path in the script above to

    Code:
    #!/bin/bash
    for i in `cat delete.txt`; do
    /scripts/tmpkillacct $i
    fi
    
    Just some suggestions :)

    -Scott
     
  3. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    I modified killacct on ours to accept a second parameter that tells it that it is being run
    from a script and should not ask for confirmations. Simple if test on "$2"
     
  4. hosteurolive

    hosteurolive Member
    PartnerNOC

    Joined:
    Jun 5, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    hi

    I used this

    #!/bin/sh

    cd /var/cpanel/suspended/
    for user in *
    do
    echo y | /scripts/killacct $user
    done


    but I need this script ignore " account suspended for bandwith limit" and to put a limit date
    ex: I want to remove only accounts before March 07

    thx
     
  5. The WebDruid

    The WebDruid Member

    Joined:
    Sep 1, 2006
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Nuke the server! That'd be the easiest way :)
     
  6. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    526
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brno, Czech Republic
    suggestion : don't write useless comments.
     
  7. brian mcgrogan

    brian mcgrogan Registered

    Joined:
    Jan 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    removing mulitple accounts

    Using /usr/local/cpanel/bin/killacct has a few problems:
    • works on one account at a time,

    • takes between 1 to 5 minutes to execute (per account)
    • restarts apache and some other critical process each time


    I a situation where I had to delete thousands of accounts, and based on my estimates, it would take anywhere from three weeks to five weeks to actually execute and finish execution, during this time, the web server would be stopped and started every two minutes, etc... There had to be a better way...

    I ran /usr/local/cpanel/bin/killacct under strace, logged its output, and wrote a tool to take in a list of usernames that need to be removed, then it goes through each of the various files, one by and one, and removes however many users you specify out of each file, writes the file back to disk, done. Thus, apache only needs to be restarted once when deleting 10000 users or 1.
     
Loading...

Share This Page