Announcement

Collapse
No announcement yet.

Scheduled Task : personnal script works manually but not automatically

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scheduled Task : personnal script works manually but not automatically

    Hi All,

    I use Task Scheduler to run personnal php script. When I submit it manually, the script is ok. it works. I can find the result and I see its entry into the job log.

    In contrast, nothing happens automatically.
    Example: the script is schedulled every 10 minutes, I see the next coming hours executions evolve in the task scheduler admin panel but I have no result and no log entry.

    it's weird because if force it manually from the "Run Now" everything goes well.

    The filescript is recorded into the good path (./includes/cron/), executed from the good product (vBulletin)

    I hope somebody can help me.
    Before you ask me to paste the code, remember that it works when i submit it manually from the task scheduler admin panel

    thanks for all

  • #2
    It won't work automatically unless you used the basic outline for the cron job from an existing cron job (in /core/includes/cron). Run Now runs the script as a stand alone, not through the Scheduled Task Manager - it runs differently. So, you could be missing lines in your code that are needed in order for it to run via the Scheduled Task Manager. Additionally, logging the jobs is wonky right now as they don't show up in order - sometimes you have to search several pages to find the logged item. Are you sure it isn't working via the Manager besides just seeing it not logged?

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to vbulletin.org
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools <- awesome site for html/css help

    Comment


    • #3
      Hello,
      first, thanks for your answer

      I created this script on the same basis as the script already present in core/includes/cron
      Some of them are quite "simple" and do not call for any specific vBulletin line, but i still follow the syntax of variables, constants, define and other objects that I have seen often (but not always)

      About the log, you right because i saw that sometimes i need to check all the pages to find something because the rank by date does not works perfectly
      BUT I check directly into the "cronlog" table from my database. This is how I'm sure it does not work automatically (manually while I found both an entry in the table)

      Comment


      • #4
        Are you setting it to log the action via the script (which I don't think works) or via the Scheduled Task Manager > Edit Task (it's actually the yes/no next to the blank option)?

        Also, are you sure the task really isn't being run besides the fact that you don't see it listed in the logs?

        Please don't PM or VM me for support - I only help out in the threads.
        vBulletin Manual & vBulletin 4.0 Code Documentation (API)
        Want help modifying your vbulletin forum? Head on over to vbulletin.org
        If I post CSS and you don't know where it goes, throw it into the additional.css template.

        W3Schools <- awesome site for html/css help

        Comment


        • #5
          Yes i do. Here the configuration :

          Scheduled Task: LNP_competPEC_L (id: 24)
          Varname : LNP_competPEC_L
          Log Phrase : {1}
          Active : Yes - Yes
          Filename : ./includes/cron/competPEC_L.php
          Product : vBulletin

          Part of the code :
          PHP Code:
          <?php if(!defined('VB_ENTRY')) die('Access denied.');
          // ######################## SET PHP ENVIRONMENT ###########################
          error_reporting(E_ALL & ~E_NOTICE);


          // ########################################################################
          // ######################### START MAIN SCRIPT ############################
          // ########################################################################
          $dateNow date('Y-m-d H:m:s');

          Request method :
          PHP Code:
          $query_TODO "SELECT * FROM xxxxxx WHERE type='L' AND etat='WAITPEC'";
          $TODO $vbulletin->db->query_read($query_TODO);
          $row_TODO mysql_fetch_assoc($TODO);
          $totalRows_TODO mysql_num_rows($TODO); 
          Log action method :

          PHP Code:
          $log_message "No match to be calculated";
          log_cron_action($log_message$nextitem1); 
          I also tried to insert the creation of a timestamped log file to make sure the proper task starts automatically.
          Result: one more time, when it is started with the Run Now button, I found my timestamped file, so the script runs correctly.

          If I wait until the task scheduler launches the script: I can not find entry in the cron log and the stamped file created to..

          I therefore concluded that the scheduler does not run the task.

          I also consulted my php_error.log file: nothing.

          However, I have an interesting idea:
          I feel that the system date is not going well. I am French and format options dates are:

          Format For Date: d / m / Y
          Format For Time: H \ hi
          Log Date Format: H: i, jS M Y

          That can explain when i start task manuelly with "run now", the system take my langage ID and my dateformat option but when it works automaticly, may be that can not woks with same parameters.

          I have still saw some part of the forum print bad date format.
          When i work with English langage ID, all the date and time in french format are ok
          when i work witch French langage ID, some date and time in french format are not ok

          example : into the Online Users widget,
          with English langage ID i see : Most users ever online was 31 at 10h41 on 14/07/2014.
          with French langage ID i see : Le record de connectés est de 31, H\hi à d/m/Y.







          Comment


          • #6
            Have you tried removing portions of your code to see if there is a specific line/section that is causing the task to not run automatically?

            Please don't PM or VM me for support - I only help out in the threads.
            vBulletin Manual & vBulletin 4.0 Code Documentation (API)
            Want help modifying your vbulletin forum? Head on over to vbulletin.org
            If I post CSS and you don't know where it goes, throw it into the additional.css template.

            W3Schools &lt;- awesome site for html/css help

            Comment


            • #7
              Hi, I solved my problems.
              I realized that in addition to not run automatically , the task blocking others (those PLANNED natively)

              I got interested in the "Next item" of the log_cron_action foncion. It was was incorrectly positioned.

              I called the function to each element found in my initial query. That is my opinion that was the problem

              So I called the function at the end of the script and now, the issue is fixed.

              Thank's for your help

              Comment


              • #8
                I'm glad you got it figured out!

                Please don't PM or VM me for support - I only help out in the threads.
                vBulletin Manual & vBulletin 4.0 Code Documentation (API)
                Want help modifying your vbulletin forum? Head on over to vbulletin.org
                If I post CSS and you don't know where it goes, throw it into the additional.css template.

                W3Schools &lt;- awesome site for html/css help

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...
                X