{"id":921,"date":"2010-06-07T16:39:00","date_gmt":"2010-06-07T20:39:00","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=921"},"modified":"2013-03-20T08:42:47","modified_gmt":"2013-03-20T12:42:47","slug":"script-to-teminate-suspended-accounts-on-a-cpanel-server","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/script-to-teminate-suspended-accounts-on-a-cpanel-server","title":{"rendered":"Script to terminate suspended accounts on a cPanel server"},"content":{"rendered":"<p><strong>How to check suspended accounts on a cPanel server and terminate them after a specific time frame?<\/strong><\/p>\n<p>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.<\/p>\n<p><strong>Create a file called terminatesuspended.sh<\/strong><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># pico \/root\/terminatesuspended.sh<\/span><\/pre>\n<\/blockquote>\n<p>Add the following code<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">for i in `find \/var\/cpanel\/suspended\/ -mtime +30 |\\<\/span>\r\n <span style=\"color: #0000ff;\">\u00a0cut -d'\/' -f5 | sed '1 d'` <\/span>\r\n <span style=\"color: #0000ff;\">do <\/span>\r\n <span style=\"color: #0000ff;\">y | \/scripts\/killacct $i;<\/span>\r\n <span style=\"color: #0000ff;\">done;<\/span><\/pre>\n<\/blockquote>\n<p>The username of suspended accounts are saved under the \/var\/cpanel\/suspended directory. The find command will search the \/var\/cpanel\/suspended\/ directory for files which are 30 days old and will pass the username to the &#8216;killacct&#8217; command.<\/p>\n<p>Save the file and set a cronjob to execute the file once in a day.<strong> <\/strong> Edit the root cronjob file<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># crontab -e<\/span><\/pre>\n<\/blockquote>\n<p>Add the following cronjob<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">0 1 * * * \/bin\/sh \/root\/terminatesuspended.sh<\/span><\/pre>\n<\/blockquote>\n<p>The above cronjob will terminate the account that is been suspended from more than 30 days at 1.00AM.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to check suspended accounts on a cPanel server and terminate them after a specific time frame?<br \/>\nMany 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.<br \/>\nCreate a file called terminatesuspended.sh<\/p>\n<p># pico \/root\/terminatesuspended.sh<\/p>\n<p>Add the following code<\/p>\n<p>for i in `find \/var\/cpanel\/suspended\/ -mtime +30 |\\<br \/>\n \u00a0cut -d&#8217;\/&#8217; -f5 | sed &#8216;1 d&#8217;`<br \/>\n [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[106],"tags":[877,875,878,876,873,874,879],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/921"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=921"}],"version-history":[{"count":10,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/921\/revisions"}],"predecessor-version":[{"id":2202,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/921\/revisions\/2202"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}