You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
1 month ago | |
|---|---|---|
| .. | ||
| Dockerfile | 3 months ago | |
| README.md | 8 months ago | |
| article_discovery.sh | 3 months ago | |
| crontab | 1 month ago | |
| index_articles.sh | 1 month ago | |
| media_discovery.sh | 3 months ago | |
| post_process_articles.sh | 1 month ago | |
README.md
🕒 Cron Job Container
This folder contains the Docker configuration to run scheduled Symfony commands via cron inside a separate container.
- Run Symfony console commands periodically using a cron schedule (e.g. every 6 hours)
- Decouple scheduled jobs from the main PHP/FPM container
- Easily manage and test cron execution in a Dockerized Symfony project
Build & Run
-
Build the cron image
From the project root:docker-compose build cron -
Start the cron container
docker-compose up -d cron
Cron Schedule
The default cron schedule is set to run every 6 hours:
0 */6 * * * root /run_commands.sh >> /var/log/cron.log 2>&1
To customize the schedule, edit the crontab file and rebuild the container.
Testing & Debugging
Manually test the command runner
You can run the script manually to check behavior without waiting for the cron trigger:
docker-compose exec cron /run_commands.sh
Check the cron output log
docker-compose exec cron tail -f /var/log/cron.log
Shell into the cron container
docker-compose exec cron bash
Once inside, you can:
- Check crontab entries:
crontab -l - Manually trigger cron:
cronorcron -f(in another session)
Customization
-
Add/Remove Symfony Commands:
Editrun_commands.shto include the commands you want to run. -
Change Schedule:
Editcrontabusing standard cron syntax. -
Logging:
Logs are sent to/var/log/cron.loginside the container.
Rebuilding After Changes
If you modify the crontab or run_commands.sh, make sure to rebuild:
docker-compose build cron
docker-compose up -d cron
Notes
- Symfony project source is mounted at
/var/www/htmlvia volume. - Make sure your commands do not rely on services (like
php-fpm) that are not running in this container.