Purges old logs from the database table
194132
def purge_old_logs(delete_before_days=7):
    
    delete_before_date = timezone.now() - timedelta(days=delete_before_days)
    logs_deleted = Log.objects.filter(
        created_on__lte=delete_before_date).delete()
    return logs_deleted
573477
def cleanup(self):
        
        now = time.time()
        expired = now - NODE_TIMEOUT
        if self.conn.zremrangebyscore(self.key, 0, expired):
            self._notify()
60870
def prune_database():
    
    now = datetime.now()
    expired = TokenBlacklist.query.filter(TokenBlacklist.expires < now).all()
    for token in expired:
        db.session.delete(token)
    db.session.commit()
1335967
public function purge()
    {
        $this->dbHandler->beginTransaction();
        $query = $this->dbHandler->createDeleteQuery();
        $tables = [
            'ezsearch_object_word_link',
            'ezsearch_search_phrase',
            'ezsearch_word',
        ];
        foreach ($tables as $tbl) {
            $query->deleteFrom($tbl);
            $stmt = $query->prepare();
            $stmt->execute();
        }
        $this->dbHandler->commit();
    }
378495
def wipe_results(self):
        
        # Clean results table
        self.db.purge_table('results')

        # Get rid of contents of data dir
        map(shutil.rmtree, glob.glob(os.path.join(self.get_data_dir(), '*.*')))
173114
private void cleanupLogs() throws IOException {
        logger.trace("Beginning log cleanup...");
        int total = 0;
        Iterator<Log> iter = getLogIterator();
        long startMs = System.currentTimeMillis();
        while (iter.hasNext()) {
            Log log = iter.next();
            total += cleanupExpiredSegments(log) + cleanupSegmentsToMaintainSize(log);
        }
        if (total > 0) {
            logger.warn("Log cleanup completed. " + total + " files deleted in " + (System.currentTimeMillis() - startMs) / 1000 + " seconds");
        } else {
            logger.trace("Log cleanup completed. " + total + " files deleted in " + (System.currentTimeMillis() - startMs) / 1000 + " seconds");
        }
    }
112049
def clear_db():
    """"""
    cursor = '0'
    while cursor != 0:
        cursor, keys = DB.scan(cursor, match='*', count=5000)
        if keys:
            DB.delete(*keys)
958339
def cleanup():
    """"""
    for sck in list(Wdb._sockets):
        try:
            sck.close()
        except Exception:
            log.warn('Error in cleanup', exc_info=True)
528821
protected function purgeOldCodesFromDatabase()
    {
        if ($this->use_database && $this->pdo_conn) {
            $now   = time();
            $limit = (!is_numeric($this->expiry_time) || $this->expiry_time < 1) ? 86400 : $this->expiry_time;

            $query = sprintf("DELETE FROM %s WHERE %s - created > %s",
                             $this->database_table,
                             $now,
                             $this->pdo_conn->quote("$limit", PDO::PARAM_INT));

            $result = $this->pdo_conn->query($query);
        }
    }
1360185
public function cleanLog()
    {
        $em = $this->getEm();
        $lifetime = array(
            Mapper\Cronjob::STATUS_SUCCESS  =>
                $this->getSuccessLogLifetime() * 60,
            Mapper\Cronjob::STATUS_MISSED   =>
                $this->getFailureLogLifetime() * 60,
            Mapper\Cronjob::STATUS_ERROR    =>
                $this->getFailureLogLifetime() * 60,
        );

        $history = $em->getRepository('AdfabCore\Entity\Cronjob')
            ->getHistory();

        $now = time();
        foreach ($history as $job) {
            if ($job->getExecuteTime()
                && $job->getExecuteTime()->getTimestamp()
                    < $now - $lifetime[$job->getStatus()]) {
                $em->remove($job);
            }
        }

        $em->flush();

        return $this;
    }
657121
def _prune_invalidated_entries(self):
        ""
        self.access_log_lock.acquire()
        self.access_log = deque(e for e in self.access_log if e.is_valid)
        self.access_log_lock.release()
204723
public function purgeExpired()
    {

        if ($this->sqlInitialized()) {
            if ($this->sql) {
                if ($this->sql->query("
                    DELETE
                        FROM `{$this->table}`
                        WHERE `expire` < NOW()
                ")) {
                    return true;
                }
            }
        }
        return false;
    }
421884
public function cleanup()
    {
        // Indexing is not implemented in eZ Publish 5 legacy search engine
        if ( $this->searchHandler instanceof LegacyHandler )
        {
            $db = eZDB::instance();
            $db->begin();
            $db->query( "DELETE FROM ezsearch_word" );
            $db->query( "DELETE FROM ezsearch_object_word_link" );
            $db->commit();
        }
        else if ( method_exists( $this->searchHandler, 'purgeIndex' ) )
        {
            $this->searchHandler->purgeIndex();
        }
    }
807968
protected function cleanupTempTables()
    {
        $dbHandle = $this->getDatabase()->getDatabaseConnection();

        $query = 'TRUNCATE ' . Database::TABLE_TMP_DEPENDS_NEEDED;
        $dbHandle->query($query);
    }
379254
def _cleanup_old_backups(self, database=None, servername=None):
        
        self.storage.clean_old_backups(encrypted=self.encrypt,
                                       compressed=self.compress,
                                       content_type=self.content_type,
                                       database=database,
                                       servername=servername)
176674
def _cleanlogs(silent=False, log_location="log"):
    
    try:
        print("cleaning up Icetea log directory.")
        shutil.rmtree(log_location, ignore_errors=silent,
                      onerror=None if silent else _clean_onerror)
    except OSError as error:
        print(error)
964298
public function cleanup()
    {
        $this->db->begin();
        $rslt = $this->db->query( 'SELECT * FROM SQLITE_MASTER' );
        $rslt->setFetchMode( PDO::FETCH_NUM );
        $rows = $rslt->fetchAll();
        foreach ( $rows as $row )
        {
            $table = $row[0];
            $this->db->exec( "DROP TABLE `$table`" );
        }
        $this->db->commit();
    }