Skip to content

Commit 93c656e

Browse files
committedJun 13, 2024
Create cronScheduleClean.php
1 parent ce1f927 commit 93c656e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
 

‎cronScheduleClean.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
require dirname(__FILE__) . '/app/bootstrap.php';
4+
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
5+
6+
class Outslide extends \Magento\Framework\App\Http
7+
implements \Magento\Framework\AppInterface {
8+
public function launch()
9+
{
10+
$appState = $this->_objectManager->get('Magento\Framework\App\State');
11+
$appState->setAreaCode('adminhtml');
12+
$resource = $this->_objectManager->get('Magento\Framework\App\ResourceConnection');
13+
$connection = $resource->getConnection();
14+
$tableName = $resource->getTableName('cron_schedule');
15+
16+
$sql = "DELETE FROM " . $tableName . " WHERE created_at < DATE_SUB(NOW(), INTERVAL 1 DAY)";
17+
18+
try{
19+
$result = $connection->query($sql);
20+
}catch(Exception $ex){
21+
print_r($ex);
22+
}
23+
24+
return $this->_response;
25+
}
26+
}
27+
28+
/** @var \Magento\Framework\App\Http $app */
29+
$app = $bootstrap->createApplication('Outslide');
30+
$bootstrap->run($app);

0 commit comments

Comments
 (0)