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.

Link to comment
Share on other sites

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?

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.