Go Back   HostGator Peer Support Forums > HostGator Peer Support Forums > Web Hosting Services

Notices

Reply
 
Thread Tools
  #1  
Old 09-24-2007, 06:21 AM
rota919 rota919 is offline
Swamp Croc
 
Join Date: Jan 2007
Location: Armagh, Northern Ireland
Posts: 323
Default Delete files / directories with cron

What are you you using to automatically delete files and folders on a site and replace them with the original ones?

I am busy writing an application and I need to ability to allow visitors to "test" the system, but need to get rid of the test info lets say every 3 hours and replace it with the original data.

It will include db info (easy enough) and files and subfolders.

I found a couple of scripts to do that with but would like to know what the rest of you suggests.
__________________
Fred
Reply With Quote
  #2  
Old 09-24-2007, 06:04 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: Delete files / directories with cron

I would put the originals in a non public area of the site, and set a cron to do a "cp" over to the test area every 3 hours.
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #3  
Old 09-24-2007, 06:22 PM
rota919 rota919 is offline
Swamp Croc
 
Join Date: Jan 2007
Location: Armagh, Northern Ireland
Posts: 323
Default Re: Delete files / directories with cron

Quote:
Originally Posted by slapshotw View Post
I would put the originals in a non public area of the site, and set a cron to do a "cp" over to the test area every 3 hours.
That's the general idea, I more interested in script suggestions.

I was looking at these examples. http://uk.php.net/copy but was wondering if anyone had a better idea.
__________________
Fred
Reply With Quote
  #4  
Old 09-24-2007, 07:12 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: Delete files / directories with cron

What script would you need?

Code:
cp -fr /home/user/theoriginal /home/user/public_html/thedestination
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #5  
Old 09-25-2007, 08:23 AM
rota919 rota919 is offline
Swamp Croc
 
Join Date: Jan 2007
Location: Armagh, Northern Ireland
Posts: 323
Default Re: Delete files / directories with cron

Thanks for this, I never used them before.

What would be the command for deleting files and directories?
__________________
Fred
Reply With Quote
  #6  
Old 09-25-2007, 08:39 AM
rota919 rota919 is offline
Swamp Croc
 
Join Date: Jan 2007
Location: Armagh, Northern Ireland
Posts: 323
Default Re: Delete files / directories with cron

Found a list of commands and usage here http://www.linuxdevcenter.com/linux/cmd/

Thanks for the pointer in the right direction.
__________________
Fred
Reply With Quote
  #7  
Old 09-25-2007, 05:37 PM
slapshotw's Avatar
slapshotw slapshotw is offline
Veteran Croc
 
Join Date: Jun 2006
Posts: 5,164
Default Re: Delete files / directories with cron

rm to remove, but if you do a cp with the -f option it forces the overwrite.
__________________
Follow me on Twitter! http://twitter.com/mrw
Reply With Quote
  #8  
Old 09-25-2007, 05:51 PM
rota919 rota919 is offline
Swamp Croc
 
Join Date: Jan 2007
Location: Armagh, Northern Ireland
Posts: 323
Default Re: Delete files / directories with cron

Yea got it thanks.
I had to use rm as well as the system allows to create subdirectories.

It is working perfectly
__________________
Fred
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 09:08 PM.