Script to terminate suspended accounts on a cPanel server

Create a file called terminatesuspended.sh
vim /root/terminatesuspended.sh

Add the following code

for i in `find /var/cpanel/suspended/ -mtime +30 | cut -d’/’ -f5 | sed ’1 d’`
do
y | /scripts/killacct $i;
done;
The suspended accounts username are saved under the /var/cpanel/suspended directory. The find command will search files under the /var/cpanel/suspended/ directory which are 30 days old and will pass the username to the ‘killacct’ command.
Save the file and set a cronjob to execute the file once in a day. Edit the root cronjob file

crontab -e
Add the following cronjob

0 1 * * * /bin/sh /root/terminatesuspended.sh

Script to terminate suspended accounts on a cPanel server

Leave a Reply

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

Fork me on GitHub