uccdev
3 months ago

Task scheduling runs every minute despite my directions

Posted 3 months ago by uccdev

Hi,

I'm scheduling my app/console/Kernel.php to run the following code every fifteen minutes:

       protected function schedule(Schedule $schedule)
       {
               Log::info('now im attmept schedule');
               $schedule->job(new ServerJob("hi"))->everyFifteenMinutes();
               Log::info('i doon');
       }

The problem is, this isn't running every fifteen minutes, it is running every ONE minute.

The schedule calls the following job:

     public function __construct($serveJob)
     {
           Log::info("Job constructor");
           $this->serveJob = $serveJob;
           self::findBBDirect();
           self::testEmail();
           Log::info("job's dun");
     }

That job's functions look, right now, like:

    public function testEmail() {
          Log::info("Test email");
          Mail::send("testCurl", [],
          function($message) { //use ($filePath)
            $message->to('[email protected]', 'Artisans Web')
            ->subject('Marco Polo');
            $message->from('[email protected]', 'Sample name');
          });
        }

        public function findBBDirect() {
          $token = $this->accessToken;
          $headers = ['Authorization: Bearer ' . $token];

          $curl = curl_init();
          $validReturn = true;
          $url = "https://my.instructure.com/api/v1/accounts/1/courses?per_page=100";

          curl_setopt_array($curl, [
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLINFO_HEADER_OUT => TRUE,
            CURLOPT_URL => $url,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_SSL_VERIFYPEER => TRUE,
            CURLOPT_HTTPHEADER => $headers,
            CURLOPT_CUSTOMREQUEST => 'GET',
            CURLOPT_HEADER => TRUE,
            CURLOPT_RETURNTRANSFER, TRUE
          ]);
          if (curl_errno($curl)) {
            Log::info('Error:' . curl_error($curl));
          } else {
            Log::info('Yep, curl is fine');
          }

          $resp = curl_exec($curl);
          $header_size = curl_getinfo( $curl, CURLINFO_HEADER_SIZE );
          $header = substr( $resp, 0, $header_size );
          $body = substr( $resp, $header_size );
    
          $data = json_decode($body, true);
          $explData = explode("\n",$resp);
          $buttons = ["Current", "Next", "Prev", "First"];
          $links = $explData[15];
          $pageLinks = explode(",", $links);
          $bbData = array_fill(0, 4, null);
          $numBBs = 0;
          foreach ($data as $d) {
            if((array_key_exists("id", $d)) && (self::hasBBDirect($d["id"]))) {
              Log::info("found BB");
              $bbData[$numBBs] = $d["id"];
              $numBBs++;
            }
          }
          curl_close($curl);
    }

It may also be of interest that this was not running irregularly until recently. I don't know what change I made to cause this, but I can't seem to go back to it.

Any ideas why this would happen?

To clarify, I've seen this thread as well: https://laracasts.com/discuss/channels/general-discussion/task-scheduling-runs-every-minute-instead-of-the-time-that-i-set . But since I am not giving any specific cron directions, or usage, I am not sure the advice within is applicable here. I am extra unsure, in fact, since just two days ago, all was working as I had expected it to. That it isn't now, I don't know what to do.

Any help would be greatly appreciated

Please sign in or create an account to participate in this conversation.