Jump to content

what is the best way to mass delete files ?


nadeemshafi

Recommended Posts

Hi guys

 

I have to mass delete 1000's of files on api call, i have a queue table but i am thinking of the best way to delete the files without crashing the server, files can range from 1mb to 10gb or more

 

idea 1. 1min cron - check to see if any pending if so exit, otherwise select 50 from queue and foreach mark as 'pending' and delete and mark as done maybe sleep. (file sizes vary so 50 could mean 1 mb or 100gb)

 

idea 2. 1sec cron - check for pending if so exit otherwise select 1 from queue mark as pending and delete then mark as done  ( I like this one )

 

idea 3 select all files with no status and foreach delete and then sleep while(file exists) ( while loop has potential of lockups )

 

I would appreciate if you could give me some thought son this I like idea 2.

 

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.