22, November 2008

delete files from a folder - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web hosting talk  >  Configuring your server
Topic: delete files from a folder
« previous next »
Pages: [1] 2 Print

Author Topic: delete files from a folder  (Read 2111 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« on: Apr 30, 2007, 10:45:44 AM »

Hi,

is there a linux command I can use with CRON to remove all files from a directory or do I need to write a small php script which has to be executed by CRON?


Last blog : Just a better Internet portal provided by Google
Tim Nash
Global Moderator
Community Supporter ?
Internet Junkie
*****
Posts: 2173
5036 credits
Members referred : 2


Venture Skills - New Media & IT group


« Reply #1 on: Apr 30, 2007, 10:51:36 AM »

rm -r yourdirectory

Would you like to be an SEO, let me help with, The Tim Nash introduction to SEO Visit through proxy alternatively for Social media optimisation take a look at the Venture Skills Blog Visit through proxy

Last blog : Its all in the mp3s
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Apr 30, 2007, 11:00:17 AM »

rm -r yourdirectory
I want to remove the files only, is this the right command to do this? (the folder need to stay there)


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #3 on: Apr 30, 2007, 02:01:32 PM »

In that case the command is

rm /path/to/*

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Tim Nash
Global Moderator
Community Supporter ?
Internet Junkie
*****
Posts: 2173
5036 credits
Members referred : 2


Venture Skills - New Media & IT group


« Reply #4 on: Apr 30, 2007, 02:11:18 PM »

rm -r directory will remove the directory

rm /path/* will remove all files, the * obviously a wildcar so you can remove only jpgs for example *.jpg

Would you like to be an SEO, let me help with, The Tim Nash introduction to SEO Visit through proxy alternatively for Social media optimisation take a look at the Venture Skills Blog Visit through proxy

Last blog : Its all in the mp3s
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Apr 30, 2007, 02:24:04 PM »

thanks people, this job will delete the files every tuesday at 0:00 right?

0   0   *   *   2   rm /home/user/domains/domain.com/public_html/cache/*


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #6 on: Apr 30, 2007, 02:34:26 PM »

thanks people, this job will delete the files every tuesday at 0:00 right?

0   0   *   *   2   rm /home/user/domains/domain.com/public_html/cache/*

Correct Smiley

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Jun 07, 2007, 04:08:45 PM »

this was another trial to remove the files (used the command above)

but get only this error:



rm: cannot remove `/home/user/domains/domain.com/public_html/cache/*': No
such file or directory


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #8 on: Jun 07, 2007, 04:58:46 PM »

That means that there are no files in this directory

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Jun 07, 2007, 05:01:24 PM »

That means that there are no files in this directory
Huh > 50.000


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #10 on: Jun 07, 2007, 05:03:45 PM »

That is strange. Do you do this as a root user? I mean do you have right to delete those files?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Jun 07, 2007, 05:06:59 PM »

That is strange. Do you do this as a root user? I mean do you have right to delete those files?

I guess it's some permission thing (I have support on that account I will check this with them) thanks


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #12 on: Jun 07, 2007, 05:15:06 PM »

If you do this with cron, you probably have no rights.

In that case you can do this :

Code:
chown nobody:nogroup -R /home/user/domains/domain.com/public_html/cache/

or use the rm command with sudo from cron.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #13 on: Jun 07, 2007, 05:20:53 PM »

I will try to enter SSH with sudo


Last blog : Just a better Internet portal provided by Google
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #14 on: Jun 07, 2007, 05:22:15 PM »

I will try to enter SSH with sudo

-bash: sudo: command not found


Last blog : Just a better Internet portal provided by Google
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #15 on: Jun 07, 2007, 05:58:40 PM »

That makes the problem bigger.... (you need to install sudo)

Did you tried to delete the files from php? I guess if the php can create those files, it will be able to delete them too using the unlink() function

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Tim Nash
Global Moderator
Community Supporter ?
Internet Junkie
*****
Posts: 2173
5036 credits
Members referred : 2


Venture Skills - New Media & IT group


« Reply #16 on: Jun 07, 2007, 06:26:54 PM »

lets start with something basic, do you have root access?
if so login to root su password
then rm

If you don't have root access then chances are you won't be able to delete the files unless they are changed to your username contact support Smiley

Would you like to be an SEO, let me help with, The Tim Nash introduction to SEO Visit through proxy alternatively for Social media optimisation take a look at the Venture Skills Blog Visit through proxy

Last blog : Its all in the mp3s
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #17 on: Jun 07, 2007, 09:33:58 PM »

That makes the problem bigger.... (you need to install sudo)

Did you tried to delete the files from php? I guess if the php can create those files, it will be able to delete them too using the unlink() function

this is an reseller hosting account and I guess they blocked that function (sudo must be installed since it is ubuntu right?)


Last blog : Just a better Internet portal provided by Google
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #18 on: Jun 07, 2007, 09:35:34 PM »

lets start with something basic, do you have root access?
if so login to root su password
then rm

If you don't have root access then chances are you won't be able to delete the files unless they are changed to your username contact support Smiley

according the information I got it should be possible because the (reseller) use have the rights. Will see what the support will tell me...

Thanks people!


Last blog : Just a better Internet portal provided by Google
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #19 on: Jun 12, 2007, 09:25:57 AM »

Ok I have that website now on my dedicated server.

I tried to remove the files as root:

rm -r /home/user_name/domains/domain.com/public_html/cache/*

but get this error now:
bash: /bin/rm: Argument list too long

is there an option I can use?

or its maybe better to delete the folder and create a new one?


Last blog : Just a better Internet portal provided by Google
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6487
Tags : cron jobs Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] 2 Print 
Webdigity Webmaster Forums  >  Web hosting talk  >  Configuring your server
Topic: delete files from a folder
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Nov 22, 2008, 04:19:01 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.736
Total Topics: 7.650
Total Members: 4.397
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Janai

40 Guests, 6 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.