January 14th, 2014, 06:22 AM
Storing files in /tmp/ directory
I have the following directories:
I wish to allow a user to temporarily store a file for less than an hour which has a random name.
Should I store in in the common /tmp/ directory, or the individual user's /tmp/ directories? How best to clean up the directories after a given amount of time?
January 14th, 2014, 06:30 AM
Unless the other users are going to need to access each others files, I'd put them in their individual folder. As for cleanup, run a cronjob that calls a shell script which tests if the file was create > 1 hour ago and if so, delete it.
Unless of course there's a database involved in which case you'd have to employ a PHP script to do the delete (unlink) and removal from the DB at the same time. But you could still use cron to run every minute to find all files > 1 hour old and pass the results via $_GET to the PHP file.
"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984
January 14th, 2014, 07:25 AM
i agree with badger_fruit's answer.......