How to Run Cron Jobs in Symfony

April 17, 2025

Alina Orel

If you’ve ever needed to run scheduled tasks in a Symfony app—like sending emails every hour, syncing data, or cleaning up logs—you’ve probably asked:

“What’s the best way to handle cron jobs in Symfony?”

Symfony doesn’t have a native scheduler like Laravel, but the community has you covered. Enter: cron/cron-bundle — a powerful tool that makes cron jobs clean, database-driven, and easy to manage.

Let’s break it down step by step—with real code and zero fluff.

🔧 What’s cron/cron-bundle?

It’s a Symfony bundle that lets you define and manage cron jobs inside your app, using Symfony console commands. You schedule jobs via cron expressions and let the bundle handle execution, logging, and more.

Think: Laravel scheduler vibes, Symfony style.

🚀 Step 1: Install the Bundle

Start by installing it via Composer:

composer require cron/cron-bundle

If you’re not using Symfony Flex, manually enable it in config/bundles.php:


✍️ Step 2: Create Your Symfony Command

Let’s say we want to send a summary email every hour. Create the command:

php bin/console make:command App\\Command\\SendSummaryEmailCommand

Update the generated file:


🗄️ Step 3: Create the Cron Job Table

The bundle provides a default cron_job table. No need to build a custom entity.

Run the migration:

Done! You’re ready to add jobs.

🧩 Step 4: Add Jobs to the Database

Add new jobs by inserting rows into the cron_job table. Key fields:

  • name: A friendly label (e.g. “Send Summary Email”)
  • command: The Symfony command to run (e.g. app:send-summary-email)
  • schedule: Standard cron expression (e.g. 0 * * * *)
  • enabled: Set to 1 to activate it

This gives you full control from the DB—no config files or code changes required.

🏃 Step 5: Run Scheduled Jobs

To execute due jobs, run:

The bundle will check the schedule and run any jobs that are due.

🔁 Automate with System Cron

To run jobs automatically, set up a system cron to trigger every minute:

Now your Symfony app is running scheduled tasks like a champ.

📝 Want to track job output?
  • Pipe the system cron output to a log file
  • Add Symfony logger calls inside your commands
  • Store job results or statuses in a custom table for auditing

You’ve got options.

✅ Recap

With cron/cron-bundle, scheduled tasks in Symfony become:

  • Dynamic – controlled via the database
  • Flexible – update jobs without touching code
  • Clean – no YAML or messy configs
  • Powerful – supports any Symfony command

You can even build an internal UI to manage jobs from your admin panel.

That’s it—cron jobs in Symfony, simplified.

We’re here to assist you with any questions about your project https://synpass.pro/contactsynpass/ 🤝