Jump to content

Time based delete


Dudditz

Recommended Posts

Noob question: I was wondering if its possible for a php file to delete itself?

 

I often upload temporary files for others to view which I do not want to remain in my webspace but for a short time.

If there is no script to delete itself, does anyone know of a snippet or something to delete based on a time() variable inside the targeted file?

 

Example:

the_deleter.php scans the first line of each file in a directory where a time() variable is placed.

It then checks that variable against a deletion time and determines either to delete the file or pass to the next file.

 

Thanks

Link to comment
Share on other sites

use cron to auto delete based on time

 

I would but wanted each file with a different deletion time.

file one - delete time 3AM

file two - delete time 1PM

file three - delete time - Dec 31,2010

 

I am attempting to write something using the unlink() currently but the time function is really messing me up.

Just thought there may be an easier approach.

 

Thanks.

Link to comment
Share on other sites

make up 3 crons pointing at a cron.php file

then check the time and delete the file

 

if (date("H")=="3"){

//it's 3 am delete the shit

@unlink($path1);

}elseif (date("H")=="13"){

//it's 1 pm delete the shit

@unlink($path2);

}elseif [...]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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