Ezilon.com - Target Your Audience, be Seen in Your Region

deleting files created with PHP

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.
Greg K's picture
Moderator

He has: 1,601 posts

Joined: Nov 2003

If you ahve the problem of deleting a bunch of files that are owned by "Nobody" becasue a php script created them, here is a cheat that may work so you do not have to write a script to delete them:

Say you have a directory of 20 files owned by nobody, and you want them all deleted. In that directory, do gzip * On my server, when this is done, it zips each one of those up, and deletes the original file, but the zip file is owned by the account I am logged in as. Now I am free to jsut delete all those zip files.

Just something I came across today while playing with the gzip command, and thought I would share it. (I test zipped a file, then unzipped it, and suddenly my php script errored our wrtiting to the original file... it no longer was the owner Wink

-Greg

PS. yes, I can just issue [B]rm *[B] and it WILL delete all the files, but it will PROMPT me on every file. If you have more than 5 or 10, this is a pain.

[This space intentionally left blank]

Cool Geek Supplies: www.ThinkGeek.com

mairving's picture
Moderator

They have: 2,256 posts

Joined: Feb 2001

That depends upon the permissions of the file. If it is owned by nobody and the permissions are 744, then you won't be able to delete it unless you are su.

FYI, rm -f removes the prompt.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

He has: 20 posts

Joined: Dec 2004

I ran into the same problem, but I don't have shell access, so it limits what I can do.

I contacted support because while I have a reseller account, I could not delete the files created with a script.

Support figured it out, and created a chron job that periodically calls a script and it flags all the files with my user name.

andy206uk's picture
DeveloperModerator

He has: 1,742 posts

Joined: Jul 2002

Or you could just delete them with a php script using unlink() Wink

Andyk

Music Rants News and Reviews | My Photoblog | Blog of a Web Designer
Give a man a fish and you feed him for a day. Teach him to use the Net and he won't bother you for weeks.