+ Reply to Thread
Results 1 to 5 of 5

Thread: PHP task scheduling

  1. #1
    as4s1n's Avatar
    as4s1n is offline x10 Sophmore as4s1n is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Washington State
    Posts
    174

    PHP task scheduling

    I have a question about scheduling tasks.

    If I have a task scheduled on a PHP page, but that page is never called/referenced, would it still run at the scheduled time?
    There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: PHP task scheduling

    How is it "scheduled"?

    For a script to run, someone/thing has to envoke it. Called as a web page, run by the cron daemon, or called from another page/script.
    Nothing is always absolutely so.

  3. #3
    as4s1n's Avatar
    as4s1n is offline x10 Sophmore as4s1n is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Washington State
    Posts
    174

    Re: PHP task scheduling

    To this effect:
    PHP Code:
    $curDate date('h');
    $dateToRun "12";
    $run 1;
     
    if(
    $curDate == $dateToRun && $run == 1) {
       
    # ... Run task ...
       # ... Set run to 0

    Last edited by as4s1n; 04-12-2010 at 11:56 AM.
    There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.

  4. #4
    essellar's Avatar
    essellar is online now Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,152

    Re: PHP task scheduling

    There's nothing there to schedule a task -- all that code will do is keep the code from running except between midnight and one AM and noon and one PM if something else calls your PHP page. The code may never run, or it may run multiple times.

    What you need to do is remove the time-sensitive code and set up a cron job to launch the PHP script instead. You can start by looking at this tutorial.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  5. #5
    as4s1n's Avatar
    as4s1n is offline x10 Sophmore as4s1n is an unknown quantity at this point
    Join Date
    Apr 2009
    Location
    Washington State
    Posts
    174

    Re: PHP task scheduling

    Oh, OK.

    BTW: Thanks for the tutorial.
    There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.

+ Reply to Thread

Similar Threads

  1. Cron Task
    By Daniel S in forum Free Hosting
    Replies: 2
    Last Post: 02-07-2008, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers