Home    Articles

 

How to list all cronjobs in your Magento

 

I don't own this code, it was taken from here: https://gist.github.com/werdan/5827225 and adapted a little bit in order to run it from magento base folder.

So all you have to do is to create a php file in your magento base folder and add this code: 

<?php
chdir(dirname(__FILE__));

require 'app/bootstrap.php';
require 'app/Mage.php';

if (!Mage::isInstalled()) {
    echo 'Application is not installed yet, please complete install wizard first.';
    exit;
}

if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
    Mage::setIsDeveloperMode(true);
}
ini_set('display_errors', 1);
Mage::$headersSentThrowsException = false;
# get all cronjobs

$cronJobs = Mage::app()->getConfig()->getNode('crontab/jobs');
$outputFormat = "%-60s %-20s %-50s";
printf($outputFormat . "\n", "Job name", "m h dom mon dow", "Object::Method to execute");
$lines = "Job name, m h dom mon dow, Object::Method to execute";
foreach($cronJobs->children() as $key => $job) {
    $expr = trim((string) $job->schedule->cron_expr);
    $datas[$key] = sprintf($outputFormat, trim($job->getName()), $expr, trim((string) $job->run->model));
    $datas_csv[$key] = array(trim($job->getName()), $expr, trim((string) $job->run->model));
}
foreach($datas as $job) {
    echo $job . "\n";
}
exit;

?>

I hope it helped.

by