1. Home
  2. Knowledge Base
  3. Server Management
  4. How can I find cPanel accounts on my server that are not integrated with WHMCS?

Question

How can I identify any cPanel account on my server that is not connected to my WHMCS billing ID?

Answer

You can use the steps below to generate a list of any cPanel account on the server without an integration link to WHMCS:

  1. Log in to your server as the _root _user via SSH.
  2. Enter the following command:

for cpuser in $(whmapi1 listaccts |awk '/user:/ {print $2}'); do apicheck=$(whmapi1 list_integration_links user="${cpuser}" | grep 'app: WHMCS'); if [[ -z "${apicheck}" ]]; then echo "${cpuser}"; fi; done

  1. A list of every cPanel account on the server without a WHMCS integration link will appear in the command’s output. For example:

Code:

# for cpuser in $(whmapi1 listaccts |awk '/user:/ {print $2}'); do apicheck=$(whmapi1 list_integration_links user="${cpuser}" | grep 'app: WHMCS'); if [[ -z "${apicheck}" ]]; then echo "${cpuser}"; fi; done user123 user456 user789

In this example, user123, user456, and _user789 _represent cPanel accounts without WHMCS integration links.

  1. For information on how to import existing cPanel accounts into the WHMCS accounting ecosystem, see the following WHMCS document:

CPanel/WHM Import – WHMCS Documentation

Alternative Solution:

We have written the following script to help locate accounts are considered ‘abandoned’ and have no link with WHMCS.

First, you would need to export a list of services which are either ‘Active’ or ‘Suspended’ via the WHMCS Reports. Generate a simple list of usernames under the filename ‘/root/active.services’ 

#!/bin/bash ACTIVEUSERLIST="/root/active.services"
rm -f /root/suspicious.all
for user in $(ls /var/cpanel/users) do owner=$(cat /var/cpanel/users/${user} |grep "OWNER="|cut -d"=" -f2) if [ ${owner} == root ] then  # owner is root(shared),so we crosscheck user grep -w ${user} ${ACTIVEUSERLIST} || echo ${user} >> /root/suspicious.all else  # owner is a reseller,so check if reseller is active grep -w ${owner} ${ACTIVEUSERLIST} || echo ${user} >> /root/suspicious.all fi done

This will produce a list of accounts in /root/suspicious.all which are considered ‘abandoned’. 

Warning

||| Please ensure you have account backups before running the above scripts or commands.

Was this article helpful?

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *