Results 1 to 2 of 2

Thread: Scheduler problem - unable to set schedule to "Inactive" when running via cron

  1. #1
    jeffdoubleyou is offline Junior Member
    Join Date
    Mar 2011
    Location
    Detroit, MI
    Posts
    3

    Default Scheduler problem - unable to set schedule to "Inactive" when running via cron

    Hello,

    I have a problem that's driving me crazy!

    In a custom module, I have a schedule created that runs every 15 minutes to process the initial setup of configuration after installing the module.

    What is supposed to happen is that upon completion, the schedule should be set to "Inactive".

    I have a schedule setup to run a URL:

    http://mysugar.com/setup_wizard.php

    In setup_wizard.php, I have the following code at the end of the script to de-activate the schedule:

    PHP Code:

    logsetup
    ("Inactivating Wizard scheduler...");
    //once done, inactivate the scheduler
    $sch = new Scheduler();

    $sch->retrieve_by_string_fields(array('name' => 'Process Wizard'));
    logsetup("Scheduler ID: ".$sch->id." Status: ".$sch->status);

    if(!empty(
    $sch->id)){
            
    logsetup("Tyring to change status to Inactive");
            
    $sch->status "Inactive";
            
    $sch->catch_up "0";
            
    $sch->save();
    }

    $sch = new Scheduler();
    $sch->retrieve_by_string_fields(array('name' => 'Process UAE Wizard'));
    $sch->status "Inactive";
    $sch->save();

    logsetup("STATUS NOW: ".$sch->status);

    logsetup("============== Setup completed at "date("Y-m-d H:i:s")."================="); 
    The second scheduler status / save was just for testing purposes and to get the status after I attempt to change it.


    When this runs via cron, the log that I'm creating says:

    Inactivating Wizard scheduler...
    Scheduler ID: 6c5510e8-a082-1720-2232-4d7506992c98 Status: In Progress
    Tyring to change status to Inactive
    STATUS NOW: Inactive
    ============== Setup completed at 2011-03-07 16:45:07=================


    However, when I go to the scheduler, it's still listed as "Active".


    If I run the URL of the wizard directly, ( i.e. http://mysugar.com/setup_wizard.php ) rather than via the scheduler / cron, it deactivates as expected.

    What am I missing here? Is it not possible to change the status of the schedule while it's running?

    Thanks in advance.

  2. #2
    jeffdoubleyou is offline Junior Member
    Join Date
    Mar 2011
    Location
    Detroit, MI
    Posts
    3

    Default Re: Scheduler problem - unable to set schedule to "Inactive" when running via cron

    Never mind, I see from looking at the code in Scheduler.php and SchedulersJob.php it doesn't seem possible to change the status of a Job from within the job itself since upon success, the Schedule status is changed to "Active" automatically ( via setJobFlag in SchedulersJob.php ).

    I guess I'll need to figure out some other way to handle the status change.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Unable to configure cron.php,scheduler & bat file plz help
    By srini123 in forum Marketing/Campaign Management
    Replies: 8
    Last Post: 2011-04-26, 07:03 AM
  2. Replies: 0
    Last Post: 2010-06-29, 08:55 AM
  3. CRON.PHP returns "Unable to select database"
    By rapesco-dm in forum Help
    Replies: 1
    Last Post: 2010-06-03, 09:01 AM
  4. "Error running count query" with get_entry_list
    By RedSerratia in forum Developer Help
    Replies: 3
    Last Post: 2008-11-18, 08:41 AM
  5. Replies: 3
    Last Post: 2007-04-23, 05:19 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •