Announcement

Collapse
No announcement yet.

Scheduled Jobs Not Working

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

  • Scheduled Jobs Not Working

    Hello,

    I have one job ControlQuoteStatus in Espo\Custom\Jobs.

    class ControlQuoteStatus extends \Espo\Core\Jobs\Base {

    public function run() {
    $list = $this->getEntityManager()->getRepository('Quote')->where(array(
    'status' => 'pending'
    ))->find();

    foreach ($list as $e) {
    $e->set('status', 'pendinggg');
    $this->getEntityManager()->saveEntity($e);
    }

    return true;
    }

    }

    Created a scheduled job with frequency 1 minute.

    In windows task scheduler task ran successfully.
    But quote table is not affected.

    I am really stuck, Can somebody help me.

    Thanks in advance
    Last edited by krishnapriya; 03-15-2018, 09:48 AM.

  • #2
    Hello
    works good.
    Do you set namespace Espo\Custom\Jobs; ?
    Do you have quote status 'pending' (in lowercase)?

    Comment


    • #3
      Hi Tanya,

      Yes namespace and quote status are the same as you said.

      I created a bat file in c:\xampp\htdocs\test\Project\task.bat and added this line=>

      c:\xampp\php\php.exe -f c:\xampp\htdocs\test\Project\cron.php

      Created new task in windows scheduler and in action I chose this task.bat to run and saved.

      Not working. Anything else should I set somewhere?

      Please help.

      Thnaks.
      Last edited by krishnapriya; 03-15-2018, 10:29 AM.

      Comment


      • #4
        Do you have any records in this job log? (Execution time and Status Success)?

        Comment


        • #5
          it is showing failed when I typed C:\xampp\apache\bin\httpd.exe -f c:\xampp\htdocs\test\Project\cron.php

          Click image for larger version  Name:	failed.png Views:	1 Size:	25.1 KB ID:	35695

          And shows nothing when used c:\xampp\php\php.exe -f c:\xampp\htdocs\test\Project\cron.php
          Last edited by krishnapriya; 03-15-2018, 10:49 AM.

          Comment


          • #6
            run c:\xampp\php\php.exe -f c:\xampp\htdocs\test\Project\cron.php in the cli and you will see the reason of failure (or you could try to search in log, but not all cron error could be logged)

            Comment


            • krishnapriya
              krishnapriya commented
              Editing a comment
              Tried Like that Tanya, But it didn't display anything. It just executed

          • #7
            Check if you have this job with status pending in the past time (this job could even not planned, when you run)

            Comment


            • krishnapriya
              krishnapriya commented
              Editing a comment
              In quotes still I have many with status as 'pending'. Checked it with mysql query.

              I tried rechecking the bat file execution in windows scheduler by changing the trigger time again.
              Last edited by krishnapriya; 03-15-2018, 11:30 AM.

          • #8
            Is there any other file I should add other than Espo\Custom\Jobs\ControlQuoteStatus.php?

            Comment


            • #9
              Only language, but it is optional

              many - how many? Do you have any workflow or hooks for Quotes. Try to change the code and change the status for only one specified quote. Maybe it fails because of big count

              Comment


              • #10
                Hi Tanya,

                For quotes I have hooks. I tried modifying the code like this

                namespace Espo\Custom\Jobs;

                use \Espo\Core\Exceptions\Error;

                class ControlQuoteStatus extends \Espo\Core\Jobs\Base {

                public function run() {
                $query = "update test set status='cancelled' where status='confirmed'";
                $pdo = $this->getEntityManager()->getPDO();
                $sth = $pdo->prepare($query);
                $sth->execute();
                }
                return true;
                }

                }

                Here Test is the table containing only 5 rows.

                Even this Test table is not updated.

                Please help.


                Comment


                • #11
                  In log failed or success?

                  Comment


                  • krishnapriya
                    krishnapriya commented
                    Editing a comment
                    nothing displayed in log

                • #12
                  cron wasn't run.
                  you can run cron in terminal, you can run cron.php in browser, if you modify this file a little for test

                  Comment


                  • #13
                    Ok Tanya, I will try like that

                    Comment


                    • #14
                      Hi Tanya,

                      When I made the changes in code of ControlQuoteStatus , tried rebuild, it worked.

                      Still don't understand why rebuild is needed after every code change in job. Clear cache alone didn't work.

                      Thank you so much for the help Tanya., its working now.

                      Comment

                      Working...
                      X