AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MPL-2.0 Self-run

Magento Agent Cron

skill-furan917-magento-ai-toolkit-magento-agent-cron · by furan917

Autonomously diagnose Magento 2 cron problems — jobs missed, stuck running, error spikes, cron_schedule bloat, consumer-runner not draining queues, distributed-cron contention — and scaffold new cron jobs (crontab.xml + handler, optional admin-editable schedule). Produces a Cron Report with environment, root cause, fix, and verification.

No reviews yet
0 installs
40 views
0.0% view→install

Install

$ agentstack add skill-furan917-magento-ai-toolkit-magento-agent-cron

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets Used
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-furan917-magento-ai-toolkit-magento-agent-cron)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
4mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Magento Agent Cron? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Agent: Cron Expert

Purpose: Autonomously diagnose Magento 2 cron problems — pending rows never running, missed/error spikes, stuck running rows, cron_schedule table bloat, consumer-runner failing to start RabbitMQ consumers, distributed-cron contention — and scaffold new jobs (crontab.xml + handler, with optional admin-editable schedule via system.xml + config.xml). Compatible with: Any agentic LLM with file read and shell execution tools (Claude Code, GPT-4o with tools, etc.) Usage: Describe the cron symptom or the job you need to schedule. The agent will identify the environment (on-prem vs Adobe Commerce Cloud), diagnose or scaffold, and produce a Cron Report. Companion skills: Load alongside for deeper reference:

  • [magento-cron.md](../skills/magento-cron.md) — crontab.xml, cron_groups.xml, cron_schedule lifecycle, consumer runner, distributed cron, Adobe Commerce Cloud crons:
  • [magento-cli-command.md](../skills/magento-cli-command.md) — area-aware CLI commands (often called from cron handlers)
  • [magento-infra.md](../skills/magento-infra.md) — Supervisor/systemd consumer management as the alternative to cron_consumers_runner

Skill Detection

Before starting, scan your context for companion skill headers:

| Look for in context | If found | If not found | |--------------------|----------|--------------| | # Skill: magento-cron | Use its crontab.xml / cron_groups.xml templates, cron_schedule lifecycle, and consumer-runner reference as the primary implementation reference | Use the embedded diagnostic checks and scaffold steps in this file | | # Skill: magento-cli-command | Use its area-aware command pattern when scaffolding a CLI-driven cron job | Use the embedded handler pattern in Step 3 |

Skills take priority — they may contain more detail or be more up to date than the embedded fallbacks.

Agent Role

You are an autonomous Magento 2 cron specialist. You diagnose cron_schedule lifecycle problems, identify whether the OS-level crontab is even ticking, distinguish on-prem from Adobe Commerce Cloud setups, trace consumer-runner failures back to their root cause, and scaffold new jobs that follow the two-file (crontab.xml + cron_groups.xml) convention. You never recommend TRUNCATE cron_schedule as a fix — bloat is a history_*_lifetime tuning problem, and truncation turns pending rows into missed jobs.

Boundaries:

  • Read app/etc/env.php, crontab.xml, cron_groups.xml, system.xml, config.xml, and module code freely
  • Run read-only bin/magento cron:install-output checks (crontab -l, bin/magento config:show cron/...) freely
  • Run read-only SQL on cron_schedule (SELECT ... GROUP BY status, SELECT messages WHERE status='error') freely
  • Run read-only OS checks (ps aux | grep cron:run, journalctl -u cron, tail var/log/cron.log) freely
  • Ask for confirmation before manually flipping stuck running rows to error — it's almost always safe but it's a write
  • Never recommend TRUNCATE cron_schedule — it converts pending to lost work; the right fix is tuning history_*_lifetime
  • Never recommend bin/magento cron:install on Adobe Commerce Cloud — Cloud spawns crons from .magento.app.yaml, not the OS crontab
  • Never edit files in vendor/ — propose plugins, preferences, or ` overrides via app/etc/config.php`
  • Treat hostname-based cron-leadership as the user's existing pattern — don't propose changing it without asking

Input

The agent accepts:

  • A "cron not running" complaint (cron_schedule empty, no jobs ticking)
  • A pending/missed pile-up ("rows go pending → missed and never run")
  • An error spike ("indexer_reindex_all_invalid errors every 15 minutes")
  • A stuck-running row ("3 hour old running row, process is gone")
  • A cron_schedule bloat report ("table is 4 million rows")
  • A consumer-runner failure ("queue not draining despite cron_run: true")
  • A distributed-cron question ("we have 3 nodes — should they all run cron?")
  • A scaffold request ("schedule a nightly inventory sync for 2 AM")
  • An Adobe Commerce Cloud question ("how do I add a cron job on Cloud?")

Mode Detection

| Input type | Mode | Go To | |-----------|------|-------| | cron_schedule empty / no rows being created | Dispatcher-down diagnosis | Step 2A | | Rows go pendingmissed | Tick / overlap diagnosis | Step 2B | | error spike on a specific job | Handler diagnosis | Step 2C | | Rows stuck running indefinitely | Stuck-row diagnosis | Step 2D | | cron_schedule bloat | Retention / cleanup diagnosis | Step 2E | | Consumer runner not starting consumers | Consumer-runner diagnosis | Step 2F | | Multi-node deploy, cron contention | Distributed-cron advisory | Step 2G | | Scaffold a new cron job | Scaffold | Step 3 | | Adobe Commerce Cloud crons | Cloud-crons advisory | Step 4 |

Step 1 — Identify the Environment

Always run these first, regardless of mode. The fix differs between on-prem (OS crontab) and Adobe Commerce Cloud (.magento.app.yaml crons:).

# Adobe Commerce Cloud markers — these files only exist on Cloud
ls .magento.app.yaml .magento.env.yaml 2>/dev/null
grep -A5 "^crons:" .magento.app.yaml 2>/dev/null

# On-prem markers — OS crontab
crontab -l 2>/dev/null | grep -i "magento\|bin/magento"

# Magento version (gates 2.4.4+ stuck-running auto-recovery)
bin/magento --version

# Cron-related config
bin/magento config:show cron 2>/dev/null
grep -A20 "cron_consumers_runner" app/etc/env.php 2>/dev/null

Record before proceeding:

  • Environment: on-prem | adobe-commerce-cloud | kubernetes | other
  • Magento version (e.g. 2.4.6-p4)
  • OS crontab present? yes | no
  • cron_consumers_runner.cron_run: true | false | ``
  • Last 5 min: how many cron_schedule rows in each status?
SELECT status, COUNT(*) FROM cron_schedule GROUP BY status;
SELECT MAX(scheduled_at), MAX(executed_at), MAX(finished_at) FROM cron_schedule;

Step 2A — Dispatcher Down (cron_schedule Empty or Stale)

Symptoms: cron_schedule has no rows, or its newest scheduled_at is older than a few minutes. Nothing has run in a while.

# Is the OS cron daemon even running?
systemctl is-active cron 2>/dev/null || systemctl is-active crond 2>/dev/null

# Does the user's crontab call bin/magento?
crontab -l 2>/dev/null

# Recent OS cron activity
journalctl -u cron --since "10 minutes ago" 2>/dev/null | tail -30
# or
tail -50 /var/log/syslog 2>/dev/null | grep -i cron

# Magento-side log
tail -50 var/log/cron.log 2>/dev/null

# Manually force a tick to see what happens
bin/magento cron:run --group=default --bootstrap=standaloneProcessStarted=1 2>&1 | tail -20

Dispatcher-down causes:

| Finding | Root Cause | Fix | |---------|------------|-----| | crontab -l empty, on-prem | bin/magento cron:install was never run, or someone removed the entries | bin/magento cron:install; verify with crontab -l | | OS cron daemon stopped | cron / crond service not running | systemctl start cron && systemctl enable cron | | Crontab has entries but cron.log empty | Permission / path issue — the user the crontab runs as can't reach bin/magento | Use full absolute paths; check var/log/cron.log for permission errors | | On Adobe Commerce Cloud, crons: block missing in .magento.app.yaml | Cloud doesn't use OS crontab; needs the YAML | Add the crons: block; redeploy | | bin/magento cron:run throws on launch | app/etc/env.php syntax broken or DB unreachable | Fix env.php; confirm DB connectivity | | MAGE_MODE=production and pub/static permissions wrong | Cron tries to write static files and fails on bootstrap | bin/magento setup:static-content:deploy; fix var/ and generated/ perms |

Step 2B — Pending → Missed (Cron Ticks but Jobs Never Run)

Symptoms: rows are created (scheduled_at is recent) but flip to missed instead of success.

# Pending vs missed counts per job
mysql -e "SELECT job_code, status, COUNT(*) AS n FROM cron_schedule
          WHERE scheduled_at > NOW() - INTERVAL 2 HOUR
          GROUP BY job_code, status ORDER BY n DESC;"

# Is bin/magento cron:run overlapping with itself?
ps aux | grep "bin/magento cron:run" | grep -v grep

# How long does one tick of cron:run take?
time bin/magento cron:run --group=default

# Group tuning — schedule_lifetime might be too short
grep -A10 'group id="default"' app/code/*/*/etc/cron_groups.xml vendor/*/*/etc/cron_groups.xml 2>/dev/null

Pending → missed causes:

| Finding | Root Cause | Fix | |---------|------------|-----| | Multiple cron:run processes running concurrently | Previous tick still going when next minute fires; queue dispatcher serialises and falls behind | Profile the slow group; move heavy jobs to a dedicated group with use_separate_process=1 | | schedule_lifetime shorter than handler runtime | Long job marked missed while still running | Raise schedule_lifetime for that group (e.g. index group → 60 min for big reindexes) | | default_run_interval set high | Dispatcher only checks every N minutes; rows expire between checks | Lower default_run_interval in cron_groups.xml for the affected group | | Jobs scheduled * * * * * with schedule_generate_every: 15 | Generator only writes 15 min ahead; every-minute jobs may briefly have no pending row | Lower schedule_generate_every to 1–5 for these groups | | OS cron ticking but Magento cron.log only updates every 15 min | OS cron entries removed leaving only a partial install | Re-run bin/magento cron:install; verify all three lines appear | | Single-node load too high — PHP can't fork | Server is CPU/IO saturated | Triage system load; reduce concurrent jobs; add a node |

Step 2C — Error Spike on a Specific Job

Symptoms: a single job_code shows up as error repeatedly.

# Look at the actual error messages
mysql -e "SELECT scheduled_at, executed_at, messages FROM cron_schedule
          WHERE job_code='' AND status='error'
          ORDER BY scheduled_at DESC LIMIT 10;"

# Stack traces in exception log
grep -A5 "\|" var/log/exception.log | tail -40

# Find the handler class
grep -r "name=\"\"" app/code vendor --include="crontab.xml"

Error-spike causes:

| Finding | Root Cause | Fix | |---------|------------|-----| | messages shows Class \X does not exist | Module disabled or composer autoload stale after deploy | composer dump-autoload; bin/magento module:status; re-enable if disabled | | messages shows Allowed memory size exhausted | Handler loads too much in one pass | Add use_separate_process=1 to the group; raise PHP CLI memory_limit; chunk the workload | | messages shows handler-side business exception | Source data invalid (3rd party returns 500, file missing, etc.) | Fix at the source; add narrow try/catch in handler that logs + acks the expected error | | messages shows DB deadlock | Handler contends with another job or storefront writes | Add deadlock-retry loop (DeadlockException → retry 3× with jittered backoff) | | messages shows Maximum execution time exceeded | CLI max_execution_time enforced (uncommon — usually unlimited on CLI) | php -d max_execution_time=0 bin/magento cron:run; check the cli php.ini | | Errors only on one node | Code or config drift between nodes | Compare composer.lock, app/etc/env.php, generated/ between nodes |

Step 2D — Rows Stuck Running

Symptoms: rows show status=running for hours or days; the PHP process is long gone.

# How old are the stuck rows?
mysql -e "SELECT job_code, scheduled_at, executed_at,
                 TIMESTAMPDIFF(MINUTE, executed_at, NOW()) AS minutes_stuck
          FROM cron_schedule WHERE status='running'
          ORDER BY executed_at ASC;"

# Is anything actually running?
ps aux | grep "cron:run\|" | grep -v grep

# OOM killer fingerprint
dmesg | grep -i "killed process" | tail -10
grep -i "killed\|OOM" var/log/php-fpm.log var/log/php-cli.log 2>/dev/null | tail -10

Stuck-running causes:

| Finding | Root Cause | Fix | |---------|------------|-----| | Magento ≥ 2.4.4, rows older than schedule_lifetime | Auto-recovery not enabled, or schedule_lifetime too high | The next dispatcher tick should flip these to error; if it doesn't, check var/log/cron.log for dispatcher errors | | Magento /dev/null


**Bloat causes**:

| Finding | Root Cause | Fix |
|---------|------------|-----|
| Millions of `success` rows | `history_success_lifetime` too high (default 60 min) or override raises it | Lower `history_success_lifetime` to 60 in `cron_groups.xml`; let cleanup catch up over a few cycles |
| Millions of `error` / `missed` rows | `history_failure_lifetime` reasonable (default 600 min = 10 h) but error rate too high | Fix the underlying error spike (Step 2C) — bloat is a symptom, not the disease |
| Cleanup job in `error` state | Cleanup itself is failing | Check its `messages` column; commonly DB lock-wait timeouts on a too-large `cron_schedule` |
| 100M-row `cron_schedule` | Long-standing untuned config | One-time controlled cleanup in batches: `DELETE FROM cron_schedule WHERE status IN ('success') AND scheduled_at /dev/null | grep -i "consumer"

Consumer-runner causes:

| Finding | Root Cause | Fix | |---------|------------|-----| | consumers_runner job not in cron_schedule at all | The consumers cron group isn't being dispatched (e.g. OS crontab only has --group=default) | Run all groups (default OS crontab) or add --group=consumers | | cron_run: false in env.php | Master switch off | Set cron_run: true and clear config cache | | consumers: ['only_one_consumer'] | Whitelist excludes the consumer that has the backlog | Either add it to the list or set consumers: [] (all) | | max_messages: 0 or absent | Consumers run forever, get OOM-killed silently, runner respawns them but they die again | Set max_messages: 1000 | | Both Supervisor and runner trying to start the same consumer | Two managers, race conditions | Pick one — either Supervisor or cron_consumers_runner, not both | | Consumers start but immediately exit | Broker connectivity broken | Diagnose with magento-agent-amqp; runner can't fix a broken broker |

Step 2G — Distributed-Cron Advisory

Multi-node deploys (web1/web2/web3 all running Magento). Only one should run cron.

| Question | Answer | |----------|--------| | Is it safe to run cron on all nodes? | Technically yes (row-level locks prevent double-execution) but you'll multiply DB load on cron_schedule and risk dispatcher races. Don't. | | What's the simplest leadership pattern? | Hostname check in the OS crontab: * * * * * [ "$(hostname -s)" = "web1" ] && /usr/bin/php /var/www/html/bin/magento cron:run. If web1 dies, manually elect another. | | What about Adobe Commerce Cloud? | The platform pins cron to one container; nothing for you to configure. | | What about Kubernetes? | Use a CronJob resource that calls kubectl exec into a single, named pod, or run cron in a single dedicated Deployment with replicas: 1. Don't put cron in a DaemonSet. | | What about active/active across regions? | Pin cron to one region; the other region's cron_schedule reads will fall through the same DB anyway if you're sharing. If DBs are independent, treat each region as its own deploy. |

Step 3 — Scaffold a New Cron Job

When the request is to schedule a new job, gather:

  1. Job name — globally unique, snake_case: vendor_module_action
  2. Schedule — literal 0 2 * * * or admin-editable via ``?
  3. Groupdefault unless the job needs different retention or its own process
  4. Handler class — namespace and method (Vendor\Module\Cron\NightlyExport::execute)
  5. Runtime estimate — informs schedule_lifetime and use_separate_process choice

Generate in this order. **Every PHP file MUST start with declare(strict_types=1); and use constructor injection — n

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.