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.

command line subdomain removal

Discussion in 'General Discussion' started by izghitu, Apr 24, 2014.

  1. izghitu

    izghitu Well-Known Member

    Joined:
    Aug 9, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    Is there any way to remove subdomains from command line in cPanel? Is there anything in /scripts/ that can help me do it?

    Please help
    Thanks
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    There are no native scripts that will remove a subdomain beyond calling API functions from the command line. You would have to use our API, or manually remove the DNS zone, cPanel user data, and the entries from all other associated files. Manually removing a subdomain could be tedious due to the number of files you must manually edit.

    Thank you.
     
  3. izghitu

    izghitu Well-Known Member

    Joined:
    Aug 9, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    There are like 12000 subdomains to remove. cPanel crashes when I remove them using the api and needs to be restarted after each 10 subdomains removed.

    Can you please list all the locations/files where I need to remove the subdomain data manually so I can script the removal and then just regenerate the apache configs/restart cpanel and other related services?

    Thanks
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    654
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Could you provide more details on how cPanel stops working? Are there any specific error messages in the /usr/local/cpanel/logs/error_log file? It's better to address this issue than to attempt to manually remove the entries in my opinion. That being said, if you want to proceed with manually removing the entries, here is a list for you to start with:

    /var/cpanel/users/$username
    /var/cpanel/userdata/$username/*
    /etc/userdatadomains
    /etc/userdomains
    /etc/localdomains

    Note that you will also need to delete the entries from the DNS zones, and rebuild the Apache configuration file after removing the entries (/scripts/rebuildhttpdconf).

    This does not include any passwd/shadow files for email accounts utilized for the subdomains. There are likely other files that would include entries for your subdomains, depending on what services were utilized. Thus, deleting them with our API is really the best choice.

    Thank you.
     
Loading...

Share This Page