ScriptInstallation.In Add me to Skype

Home
Services
PHP Script Installation
CGI Script Installation
Linux Tips
FreeBSD Tips
Windows Tips
Server Tips
Scripts Directory
HOW-TO
Contact Us


Home > Server Administration > Linux Server Tips > Deleting

Deleting Large Number of files

Today i have written a PHP script to delete large number of files on a folder. The folder contains too many files with extension .dat. These files are mail storage of HiveMail script. The folder size was 37 GB. The mail service is stoped as the HiveMail is overkilling the server, mainly because it use a catch all email account.

When i try to delete files with rm -rf command on SSH putty get closed. So i write a simple PHP file to delete all files in the folder.


<?php

if ($handle = opendir('/home/bizhatc/mailbox')) {

while (false !== ($file = readdir($handle))) {
  $file = "/home/bizhatc/mailbox/" . $file;
  unlink ("$file");
  echo "$file";
 }

closedir($handle);

}

?>



Copyright © ScriptInstallation.in