Created
March 13, 2023 16:24
-
-
Save dfelton/b30f7595bcb67324849352981b416351 to your computer and use it in GitHub Desktop.
Magento - Output XML configured cron jobs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# - Finds all crontab.xml files within a Magento project | |
# - Collects all group name, job name, and schedules within these files | |
# - Outputs to screen this information, sorted by group & job name | |
# | |
php -r ' | |
$results = []; | |
$files = explode(PHP_EOL, "'"$(find vendor/*/*/etc app/code/*/*/etc -type f -name crontab.xml)"'"); | |
foreach ($files as $file) { | |
$xml = simplexml_load_string(file_get_contents($file)); | |
foreach ($xml->group as $group) { | |
$groupName = (string) $group->attributes()->id; | |
if (!is_array($results[$groupName] ?? null)) { | |
$results[$groupName] = []; | |
} | |
foreach ($group->job as $job) { | |
$results[$groupName][(string) $job->attributes()->name] = (string) $job->schedule; | |
} | |
} | |
} | |
ksort($results); | |
foreach ($results as $groupName => $jobs) { | |
ksort($jobs); | |
echo "\nGROUP: $groupName\n"; | |
foreach ($jobs as $jobName => $schedule) { | |
echo sprintf("\t%s\t%s\n", str_pad($schedule, 16), $jobName); | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment