Remove application logs

@param Schedule $scheduler
@return void
510981
private function removeLogs(Schedule $scheduler)
  {
    $scheduler->call(function () {
      $searchDir = Config::$root . 'storage' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR;

      $prefix = config('app.logger.name');
      $logs = glob($searchDir . $prefix . '-*-*-*.log');

      if (count($logs) < 1) return;

      foreach($logs as $log) {
        $date = str_replace($prefix . '-', '', Filesystem::name($log));
        $end = new Carbon($date);
        $now = Carbon::now();

        if ($now->diffInDays($end) > config('app.logger.keep')) {
          try {
            Filesystem::delete($log);
          } catch (\Exception $e) {
            // do nothing...
          }
        }
      }
    })->daily();
  }
132953
public function generateScheduler($scheduler)
    {
        if (count($this->scheduler)) {
            return $this->scheduler;
        }

        $history = Scheduler::where('scheduler_id', $scheduler->id)->get()->groupBy(function($item) {
            return $item->created_at->format('Y-m-d');
        })->map(function ($row) {
            return round($row->avg('time_to_run'), 2);
        });

        // Fill the array gaps - because the chart wont populate correctly without 0 values
        for($i=20; $i>=0; $i--) {
            $this->scheduler['day'][] = Carbon::now($scheduler->timezone)->subDay($i)->format('d');

            if (isset($history[Carbon::now($scheduler->timezone)->subDay($i)->format('Y-m-d')])) {
                $this->scheduler['count'][] = $history[Carbon::now($scheduler->timezone)->subDay($i)->format('Y-m-d')];
            } else {
                $this->scheduler['count'][] = 0;
            }
        }

        return $this->scheduler;
    }
356831
public function actionClearLogs()
    {
        $deleted = LogDbTargetModel::deleteAll([
            '<=', 'log_time', \Yii::$app->formatter->asTimestamp(time()) - (int) \Yii::$app->logDbTargetSettings->storeLogsTime
        ]);

        $this->stdout('storeLogsTime: ' . \Yii::$app->logDbTargetSettings->storeLogsTime . "\n");
        $this->stdout('Clear logs: ' . $deleted . "\n");

        \Yii::info(\Yii::t('skeeks/logdb/app', 'The number of remote logging') . ": " . $deleted);
    }
945148
public void clearAllSchedulingData(T jedis) throws JobPersistenceException, ClassNotFoundException {
        // delete triggers
        for (String jobHashKey : jedis.smembers(redisSchema.jobsSet())) {
            removeJob(redisSchema.jobKey(jobHashKey), jedis);
        }

        // delete remaining jobs
        for (String triggerHashKey : jedis.smembers(redisSchema.triggersSet())) {
            removeTrigger(redisSchema.triggerKey(triggerHashKey), jedis);
        }

        // remove calendars
        for (String calendarHashKey : jedis.smembers(redisSchema.calendarsSet())) {
            removeCalendar(redisSchema.calendarName(calendarHashKey), jedis);
        }
    }
426564
public function setScheduler(\CampaignChain\CoreBundle\Entity\Scheduler $scheduler = null)
    {
        $this->scheduler = $scheduler;

        return $this;
    }
685677
public function deleteSchedulingObject($principalUri, $objectUri)
    {
        $stmt = $this->pdo->prepare('DELETE FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?');
        $stmt->execute([$principalUri, $objectUri]);
    }
705770
public function remove($class, $method)
    {
        $callback = $class . '::' . $method;
        if (isset($this->configs['instances'][$callback])) {
            unset($this->configs['instances'][$callback], $this->configs['log'][$callback]);
            App::$Properties->writeConfig('Cron', $this->configs);
        }
    }
835842
public function remove(Log $log)
    {
        unset($this->logs[spl_object_hash($log)]);
        $this->level = null;
    }
878931
public function clear($date, RequestListener $listener)
    {
        app('antares.logger')->setOld(['name' => app('logger.filesystem')->getLogFilename($date)])->keep('high');
        if (app('logger.filesystem')->delete($date)) {
            return $listener->clearSuccess();
        }
        return $listener->clearFailed();
    }
444110
protected function notifyIfChanges($scheduler)
    {
        if (is_null($scheduler->healthy)) {
            return;
        }

        if ($this->wasUpAndIsNowDown($scheduler)) {
            $scheduler->healthy = false;
            $scheduler->save();

            if ($scheduler->alert_on_missed) {
                $this->eye->notifier()->alert(new Missed(['scheduler' => $scheduler]));
            }
        }
    }
324627
public function purgeAll() {
		if ($this->log) {
			if ($this->log instanceof LoggerInterface) {
				$this->log->info("Purging the whole file cache.");
			} else {
				$this->log->trace("Purging the whole file cache.");
			}
		}
        self::rrmdir($this->getDirectory());
	}
780516
public function deleteDuplicates()
    {
        $cron_schedule = Mage::getSingleton('core/resource')->getTableName('cron_schedule');
        $conn = Mage::getSingleton('core/resource')->getConnection('core_read');

        // TODO: Direct sql is not nice. We can do better... :)
        $results = $conn->fetchAll("
			SELECT
				GROUP_CONCAT(schedule_id) AS ids,
				CONCAT(job_code, scheduled_at) AS jobkey,
				count(*) AS qty
			FROM {$cron_schedule}
			WHERE status = '" . Aoe_Scheduler_Model_Schedule::STATUS_PENDING . "'
			GROUP BY jobkey
			HAVING qty > 1;
		");
        foreach ($results as $row) {
            $ids = explode(',', $row['ids']);
            $removeIds = array_slice($ids, 1);
            foreach ($removeIds as $id) {
                Mage::getModel('cron/schedule')->load($id)->delete();
            }
        }
    }
610763
public function start($args = null, $scheduler = false)
    {
        if ($args === null) {
            $this->outputTitle($scheduler ? 'Creating the scheduler worker' : 'Creating workers');
        } else {
            $this->runtime = $args;
        }

        if ($scheduler) {
            if ($this->runtime['Scheduler']['enabled'] !== true) {
                $this->output->outputLine('Scheduler Worker is not enabled', 'failure');
                return false;
            }

            if ($this->ResqueStatus->isRunningSchedulerWorker()) {
                $this->output->outputLine('The scheduler worker is already running', 'warning');
                return false;
            }

            $args['type'] = 'scheduler';
        }


        $pidFile = (isset($this->runtime['Fresque']['tmpdir']) ?
                        $this->runtime['Fresque']['tmpdir'] : dirname(__DIR__) . DS . 'tmp' )
                        . DS . str_replace('.', '', microtime(true));
        $count = $this->runtime['Default']['workers'];

        $this->debug('Will start ' . $count . ' workers');

        for ($i = 1; $i <= $count; $i++) {

            $libraryPath = $scheduler ? $this->runtime['Scheduler']['lib'] : $this->runtime['Fresque']['lib'];
            $logFile = $scheduler ? $this->runtime['Scheduler']['log'] : $this->runtime['Log']['filename'];
            $resqueBin = $scheduler ? './bin/resque-scheduler.php' : $this->getResqueBinFile($this->runtime['Fresque']['lib']);

            $libraryPath = rtrim($libraryPath, '/');

            // build environment variables string to be passed to the worker
            $env_vars = "";
            foreach($this->runtime['Env'] as $env_name => $env_value) {
                // if only the name is supplied, we get the value from environment
                if (strlen($env_value) == 0) {
                    $env_value = getenv($env_name);
                }
                $env_vars .= $env_name . '=' . escapeshellarg($env_value) . " \\\n";
            }

            $cmd = 'nohup ' . ($this->runtime['Default']['user'] !== $this->getProcessOwner() ? ('sudo -u '. escapeshellarg($this->runtime['Default']['user'])) : "") . " \\\n".
            'bash -c "cd ' .
            escapeshellarg($libraryPath) . '; ' . " \\\n".
            $env_vars .
            (($this->runtime['Default']['verbose']) ? 'VVERBOSE' : 'VERBOSE') . '=true ' . " \\\n".
            'QUEUE=' . escapeshellarg($this->runtime['Default']['queue']) . " \\\n".
            'PIDFILE=' . escapeshellarg($pidFile) . " \\\n".
            'APP_INCLUDE=' . escapeshellarg($this->runtime['Fresque']['include']) . " \\\n".
            'RESQUE_PHP=' . escapeshellarg($this->runtime['Fresque']['lib'] . DS . 'lib' . DS . 'Resque.php') . " \\\n".
            'INTERVAL=' . escapeshellarg($this->runtime['Default']['interval']) . " \\\n".
            'REDIS_BACKEND=' . escapeshellarg($this->runtime['Redis']['host'] . ':' . $this->runtime['Redis']['port']) . " \\\n".
            'REDIS_DATABASE=' . escapeshellarg($this->runtime['Redis']['database']) . " \\\n".
            'REDIS_NAMESPACE=' . escapeshellarg($this->runtime['Redis']['namespace']) . " \\\n".
            'REDIS_PASSWORD=' . escapeshellarg($this->runtime['Redis']['password']) . " \\\n".
            'COUNT=' . 1 . " \\\n".
            'LOGHANDLER=' . escapeshellarg($this->runtime['Log']['handler']) . " \\\n".
            'LOGHANDLERTARGET=' . escapeshellarg($this->runtime['Log']['target']) . " \\\n".
            'php ' . escapeshellarg($resqueBin) . " \\\n";
            $cmd .= ' >> '. escapeshellarg($logFile).' 2>&1" >/dev/null 2>&1 &';

            $this->debug('Starting worker (' . $i . ')');
            $this->debug("Running command :\n\t" . str_replace("\n", "\n\t", $cmd));

            $this->exec($cmd);

            $this->output->outputText($scheduler ? 'Starting scheduler worker ' : 'Starting worker ');

            $success = false;
            $attempt = 7;
            while ($attempt-- > 0) {
                for ($x = 0; $x < 3; $x++) {
                    $this->output->outputText(".", 0);
                    usleep(self::$checkStartedWorkerBufferTime);
                }

                if (false !== $pid = $this->checkStartedWorker($pidFile)) {

                    $success = true;
                    $this->output->outputLine(' Done', 'success');

                    $this->debug('Registering worker #' . $pid . ' to list of active workers');

                    $workerSettings = $this->runtime;
                    $workerSettings['workers'] = 1;
                    if ($scheduler) {
                        $this->ResqueStatus->registerSchedulerWorker($pid);
                    }
                    $this->ResqueStatus->addWorker($pid, $workerSettings);

                    break;
                }
            }

            if (!$success) {
                $this->output->outputLine(' Fail', 'failure');
            }
        }

        if ($args === null) {
            $this->output->outputLine();
        }
    }
397001
public function removeScheduledAliases()
    {
        foreach ($this->scheduledRemoveAlias as $alias) {
            $this->aliasing->removeAlias($alias);
        }

        $this->scheduledRemoveAlias = [];
    }
802139
def remove_lock(self):
        
        key = '%s_lock' % self.scheduler_key

        if self._lock_acquired:
            self.connection.delete(key)
1294382
def schedule_deleted(sender, instance, **kwargs):
    
    from contentstore.tasks import deactivate_schedule

    deactivate_schedule.delay(str(instance.scheduler_schedule_id))
51512
private function removeJobs()
    {
        foreach ($this->cronjobs as $jobName => $jobConfig) {
            // remove schedule in case it changed after being installed
            unset($jobConfig['schedule']);
            $this->scheduler->removeJob($jobName, $jobConfig);
        }
    }