Example #1
0
 /**
  * sets the background jobs execution type
  *
  * @param string $type execution type
  * @return false|null
  *
  * This method sets the execution type of the background jobs. Possible types
  * are "none", "ajax", "webcron", "cron"
  */
 public static function setExecutionType($type)
 {
     return \OC_BackgroundJob::setExecutionType($type);
 }
Example #2
0
 if ($appmode == 'none') {
     TemporaryCronClass::$sent = true;
     if (OC::$CLI) {
         echo 'Background Jobs are disabled!' . PHP_EOL;
     } else {
         OC_JSON::error(array('data' => array('message' => 'Background jobs disabled!')));
     }
     exit(1);
 }
 if (OC::$CLI) {
     // Create lock file first
     TemporaryCronClass::$lockfile = OC_Config::getValue("datadirectory", OC::$SERVERROOT . '/data') . '/cron.lock';
     // We call ownCloud from the CLI (aka cron)
     if ($appmode != 'cron') {
         // Use cron in future!
         OC_BackgroundJob::setExecutionType('cron');
     }
     // check if backgroundjobs is still running
     if (file_exists(TemporaryCronClass::$lockfile)) {
         TemporaryCronClass::$keeplock = true;
         TemporaryCronClass::$sent = true;
         echo "Another instance of cron.php is still running!" . PHP_EOL;
         exit(1);
     }
     // Create a lock file
     touch(TemporaryCronClass::$lockfile);
     // Work
     $jobList = \OC::$server->getJobList();
     $jobs = $jobList->getAll();
     foreach ($jobs as $job) {
         $job->execute($jobList, $logger);
 /**
  *
  * @return boolean
  */
 public function isCronEnabled()
 {
     return \OC_BackgroundJob::getExecutionType() == 'cron';
 }