Cronjobs
Edit on GitHubSpryker applications demand performing repetitive background operations called jobs. Such operations are necessary for synchronizing denormalized data into the search engine or key-value store. For Spryker applications to operate properly, we recommend running predefined jobs.
While setting up and configuring a scheduler, a developer is to solve the following tasks:
- Propagate predefined jobs into a scheduler.
- Get jobs to run on remote servers. This is an environment-dependent task.
- Set up the monitoring of job execution. A scheduler can manage this.
Cronjob schedulers are supported and controlled by the Scheduler module. The module is an abstraction layer that provides basic functionality, like reading the configuration of jobs from a source or filtering jobs according to the store configuration.
Basic module schema:
Cronjob schedulers
Demo Shops are shipped with Jenkins as a default scheduler. Jenkins manages running and monitoring jobs. If you migrated to another scheduler and want to migrate back to Jenkins, see Migrate to Jenkins.
If your project has very specific requirements, you can create a custom scheduler.
Using cronjob schedulers
The Scheduler
module provides the following commands:
Set up jobs:
// Sets up jobs for all enabled schedulers
vendor/bin/console scheduler:setup
// An example of configuration
$config[SchedulerConstants::ENABLED_SCHEDULERS] = [
SchedulerConfig::SCHEDULER_JENKINS, //jenkins
SchedulerConfig::SCHEDULER_OWN, //crontab
SchedulerConfig::SCHEDULER_JENKINS_SECOND, //jenkinsSecond
];
// Sets up schedulers that will be executed
vendor/bin/console scheduler:setup -s {scheduler_name} -s ...
Suspend jobs:
// Suspends jobs for all enabled schedulers
vendor/bin/console scheduler:suspend
// Suspends jobs for the selected and enabled scheduler
vendor/bin/console scheduler:suspend -s {scheduler_name} -s ...
// Suspends one or several jobs for specific scheduler
vendor/bin/console scheduler:suspend -s {scheduler_name} -j {job_name}
Resume jobs:
// Resumes jobs for all enabled schedulers
vendor/bin/console scheduler:resume
// Resumes jobs for the selected and enabled scheduler
vendor/bin/console scheduler:resume -s {scheduler_name} -s ...
// Resumes one or several jobs for specific scheduler
vendor/bin/console scheduler:resume -s {scheduler_name} -j {job_name} -j ...
Clean jobs:
// Cleans jobs for all enabled schedulers
vendor/bin/console scheduler:clean
// Cleans jobs for the selected schedulers
vendor/bin/console scheduler:clean -s {scheduler_name} -s ..
Cron generates jobs only for the current store. To generate jobs for a specific store, execute APPLICATION_STORE=US vendor/bin/console scheduler:*
.
Thank you!
For submitting the form