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:

Log in to your server as the root user via SSH.
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

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.

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?
Cancel
Thank you!