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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.