#1
  1. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,034
    Rep Power
    535

    Storing files in /tmp/ directory


    I have the following directories:

    Code:
    /tmp/
    /var/www/private/user1/tmp/
    /var/www/private/user2/tmp/
    /var/www/private/user3/tmp/
    ...
    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?
  2. #2
  3. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,112
    Rep Power
    487
    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
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2014
    Location
    Bangalore
    Posts
    1
    Rep Power
    0
    i agree with badger_fruit's answer.......

IMN logo majestic logo threadwatch logo seochat tools logo