Add and configure cronjobsEdit on GitHub
This document shows how to add and configure cronjobs in Jenkins.
We use Jenkins for cronjob scheduling. Compared to Crontab, there are several benefits:
- Jobs are queued and can be manually executed.
- Job definitions are under version control and can be changed by any developer.
- Console output is available for debugging.
Add a new job and run it
Jobs are defined in
This file contains an array defining the jobs.
// Send emails every 10 minutes $jobs = [ 'name' => 'send-mails', 'command' => '$PHP_BIN vendor/bin/console mail:send-mail', 'schedule' => '*/10 * * * *', 'enable' => true, 'stores' => ['DE', 'FR'], ];
To import this configuration to Jenkins, run the following command in the console. In a production environment, this is part of the deployment process.
After this, you can open Jenkins on port
10007 and watch your scripts running: http://zed.mysprykershop.com:10007 (URL works for standard VM, you may use a different hostname).
For each job you can define several configurations:
|name||string||Name of the job.||yes|
|command||string||The console command that is executed.||yes|
|schedule||string||Expression that defines the job schedule (how often the job is executed).The schedule string is compatible with cronjob schedule definition—for example,
|enable||bool||Enable or disable jobs.||yes|
|stores||array||An array of stores where the job is executed.||yes|
When you don’t use Jenkins for job scheduling, there is no locking between concurrently running commands.
For submitting the form