Jump to content

get a script to run once a week


bobinindia

Recommended Posts

there are at least 2 practical solutions and 1 silly solution.

 

practical:

1. use crontab to run your scripts whenever you want

2. run a script any time someone accesses your site that checks to see if it's time to run the other scripts. this isn't very precise and much more difficult to code than just having crontab run the scripts whenever you want them to run.

 

silly:

3. create a script that always runs, checking to see if it's time to do other stuff. when it's time to do other stuff, it does it, else it keeps looping or sleep()-ing forever. you'd essentially be re-creating crontab very inefficiently.

Your second practical option is fine for me

if (date("D")=="31") {
$dir = "images/changer/";
function empty_dir ($dir)
{
$files = glob($dir."*");
foreach($files as $file)
{
	if(is_dir($file))
	{
		if($file != "." && $file != "..")
			empty_dir($dir.$file."/");
	}
	else
		unlink($file);
}
}
empty_dir($dir);
}

Adequate for my needs.

By the way do you know how to mark a topic as solved?

Archived

This topic is now archived and is closed to further replies.

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