Files owned by 'dhapache'


#1

I went to delete the files under an installation of Smarty (a PHP templating system) but there was a whole bunch of subdirectories and files owned by user/group ‘dhapache’, so I couldn’t delete them. rm -rf doesn’t work.

I suspect these are files that were created runtime by PHP and so are given the permissions of the dhapache daemon.

Is there any way for me to delete these files, or should I just leave them there?


#2

You’ll need to put in a support request to have them deleted. (note: from my own experience – when they say it’s done doublecheck that they got everything you wanted deleted)


#3

I think you could also probably write a PHP script to remove them.


#4

Here is a PHP script that will go through all of the directories in $startpath, and delete files that are owned by “dhapache”… USE WITH CAUTION, BACKUP YOUR FILES BEFORE RUNNING!! View the source of this page and copy the code from there so that you get the accurate spacing.

<?php $startpath = "/home/.raggs/DH_USERNAME/PATH/PATH/"; function ls($curpath) { $dir = dir($curpath); while ($file = $dir->read()) { if($file != "." && $file != "..") { if (is_dir($curpath.$file)) { $stat = stat($curpath.$file); if ($stat[4] == 999) { // Once all of the dhapache files are deleted, uncomment the following line and refresh to delete the directories. Non-empty dirs will not be deleted, so any files not owned by "dhapache" may need to be manually deleted via FTP in order to delete the dhapache-owned directory. // rmdir($curpath.$file); echo("$file - $stat[4]" . '
'); } ls($curpath.$file."/"); } else { $stat = stat($curpath.$file); if ($stat[4] == 999) { unlink($curpath.$file); echo("$file - $stat[4]" . '
'); } } } } $dir->close(); return; } ls($startpath); ?>

#5

Thanks, that did the trick!

For nested subdirectories I kept hitting F5 to reload the script until it finished the job.


#6

nice!! i had totally forgotten about this thread. glad it worked for you! as a side note, i guess that viewing the source and copying does not preserve spacing as i thought it would. The spacing will have to be added manually if you are worried about that sort of thing. Eventually I might post the code on my blog and link it.


#7

Did you notice the date on my original question? It’s been a few years :slight_smile:

I just copied the code, pasted into notepad and that was it. Spacing isn’t important - this isn’t Python, after all.

However, you could add the code into the dreamhost wiki and use the < pre > tag for preformatted.