How to check suspended accounts on a cPanel server and terminate them after a specific time frame?
Many a times you suspend an account on the server and it goes unnoticed for months thus wasting disk space of your server. You can use the following script and schedule it to execute, say once in a day which will delete the suspended accounts from the server.
Create a file called terminatesuspended.sh
pico /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
The above cronjob will terminate the account that is been suspended from more than 30 days at 1.00AM.
Tags: cpanel server and suspended accounts, cronjob to terminate old accounts, how to list old suspended accounts in cpanel?, scheduler to terminate accounts, Script to teminate suspended accounts, terminate suspended accounts in a cpanel server, where are suspended accounts listed in cpanel
