Jump to content

scheduled chunks of code


edawg

Recommended Posts

What I want to do is have a chunk of my code for my website only be accessed once a week on a set day. its basically a poll, that I want to find the highest rating for, but not all the time, I want for it to be once a week.....

 

Any ideas??. thanks

Link to comment
Share on other sites

One way would be:

 

if(date("l") == "Monday) {
//do stuff
}

 

That's where you're wrong :)

 

if(date("l") == "Monday"){
//do stuff
}

 

I just had to.

 

The trouble with that is the page needs to be accessed, if you want it to be independent of that, use a cron job. 

You set a cronjob by using a broswer like "wget or lynx" to open your page "http:www.example.com".

30 * * * 0 * wget -q http://www.example.com/script.php

this will run your script every sunday at 12:30am.

Check out this site to learn more about cron http://www.unixgeeks.org/security/newbie/unix/cron-1.html.

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.