Unix Guru - need your help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qw12er
    Confirmed User
    • Apr 2004
    • 799

    #1

    Unix Guru - need your help

    How can I set file to expire by themself ?

    I'm creating files in PHP for download but once it has been downloaded I what the file to be destroyed. How can I do that ?

    Can I put an expiration date like time() + 3600; so the serveur would destroy the file an hour after creation ?

    Thanks a lot and
    Happy new year !
    I have nothing to advertise ... yet.
  • etech
    Confirmed User
    • Feb 2004
    • 1148

    #2
    add a timestamp to the filename, and when you are creating a new file, see if there are any files that are older than n minutes. if so, delete it.

    Comment

    • hive
      Worker Bee
      • Apr 2003
      • 90

      #3
      crontab this hourly

      find /path/files/are/in/ -type f -mmin +60 -print


      replace the -print with -delete AFTER YOU HAVE VERIFIED it finds the right files to delete.

      Comment

      • qw12er
        Confirmed User
        • Apr 2004
        • 799

        #4
        thank you guys.


        Do you know if the tmpfile function in PHP use the memory to create the file or does it write it on the HD ? This could fix my problem...
        I have nothing to advertise ... yet.

        Comment

        Working...