Question

I am experimenting with php unlink(), what I want to do is run a php script that deletes files created every few minutes after parsing them. I can do that with a cron or as continuously running the file that handles parse/delete on the background. What I want to ask is will deleting files every few minutes, cause problems to my web server or is there any performance downgrade when doing this or some other negative effect I can't think of?

Also how can I create a queue of files to process and dispose with php? Is that any different that what I described above?

Any help is greatly appreciated, I am a bit lost on this.

Was it helpful?

Solution

I think the approach would be based on some variables...

  1. Are you wanting to do this for a user-session?
  2. Are you wanting to do it strictly based on time?
  3. The images you are creating, are they stored or referenced globally?
  4. Are these images being used for any extended period of time, does that time change anything?

The easiest solution, in my opinion would be to create a cron job. If you can store the image and creation date (db or session), when your cron runs it can evaluate creation time vs script run-time and execute appropriately.

You have a lot of other options, but I think it comes down to the variables listed. Hope this helps.

OTHER TIPS

Parsing the files will probably produce a higher load than deleting them afterwards. Without knowing more about what your parse processing and your server environment it will be impossible to say whether there will be any noticeable performance degradation.

I would create a MySQL table to hold a list of files to process. You can then add entries to the table from one script and remove them after parsing/deleting them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top