Documentation

Before Purchasing

Before purchasing and installing, please check that you can run each installed job successfully from the dashboard. If a job will not run from the dashboard, this addon will not solve your problem.

If you don’t want to run various jobs at different schedules, have a look at Nontab Scheduler. Its free!

Support in concrete 5.4.x

FlexJob Scheduler provides all its easy to use facilities for concrete5.5 or above.

For concrete4.x versions, a reduced dashboard interface is provided where the site admin can enter cron strings that FlexJob Scheduler will then process and trigger jobs. In concrete5.5 and above, you get an easy to use dialog driven interface.

Before Installing

This addon is incompatible with Nontab Scheduler. If you have Nontab Scheduler installed, please uninstall it first.

Getting Started

FlexJob Scheduler provides a dashboard interface at System & Settings > Optimization > FlexJob Scheduler.

When first installed, all your jobs will be listed with no schedule settings. To schedule a job, click on the edit icon and a dialog will pop up.

Use the tabs and checkboxes to select when you want the job to run by ticking for time of day in hours/minutes, weekdays and day/month. Leave any of these set as "Any" if you don’t care.

Unlike pure cron, FlexJob scheduler treats an entry of "Any" for all schedule settings to mean that a job will never be run.

Be careful about selecting a weekday and a day of month at the same time. The relationship between each setting is "and", so such a job will only be run when that weekday occurs on that day of the month!

To check the schedule is what you want, go to the "Preview run times" tab to see a list of calculated run times.

The "Notes" tab keeps notes just within FlexJob Scheduler, so you can make notes of why you have configured each shedule.

Remember to preview run times to check that a job schedule is correct before clicking "Save" when finished.

Repeat the above for each job. Where schedules could collide, you can adjust the priority by dragging jobs up and down the list.

With all your jobs entered, go to the "Configuration" tab and make sure FlexJob Scheduler is enabled.

Finally, remember to "Save" the entire dialog to make sure the individual job schedules you have entered are saved.

That’s it. Your jobs are now scheduled. For the next few days, keep an eye on the Jobs Log to confirm that everything is running as it should.

At any time in the future, you can re-visit the FlexJob Scheduler dashboard page to preview the next scheduled run time of all jobs, or to edit the schedules and save again.

Jobs Log

FlexJob Scheduler also provides a dashboard page to view, search and manage the Jobs Log. This is a log that is already kept by concrete5 that FlexJob Scheduler now provides a dashboard interface to.

More about "Poor Man's Cron"

The technique generally referred to as "poor man's cron" piggybacks the triggering of jobs to visitors viewing pages. Once triggered, the actual jobs are then run in the background, so have no impact on the user's experience of a site.

Run times are approximate. FlexJob Scheduler works by piggy-backing its trigger processing onto page requests, so jobs are only run if pages are requested. The scheduled run times are therefore only approximate. If no pages are visited until 2 hours after a scheduled run time has elapsed, then the job will be delayed until then and the next run time calculated from when the job was run.

The busier a site is, the more accurately FlexJob Scheduler will run a job to its schedule.

FlexJob Scheduler should therefore only be used to run jobs that are not time critical.

Because jobs are triggered by page requests, there is a small possibility that a job can be double-triggered by concurrent page requests. FlexJob Scheduler includes checks to prevent double triggering and further checks to prevent double execution. However, there remains a tiny but finite possibility of a job being double executed. This must be borne in mind by developers when designing jobs.

Within FlexJob Scheduler time is available in 5-minute intervals. If you need to run jobs with more precision, then you really need a proper cron service. FlexJob Scheduler does not provide precise enough control of time for such a critical schedule.

Options

Enable FlexJob Scheduler

Globally enable/disable FlexJob Scheduler.

Log job execution times

All jobs are logged to the Jobs Log by concrete5. In addition, you can configure FlexJob Scheduler to log exact job execution times to the main concrete5 Log. This can be a useful diagnostic if jobs are failing because their execution times are overrunning.

FlexJob Scheduler also logs any errors when executing jobs to the main concrete5 Log.

Method by which jobs are run

FlexJob Scheduler provides a selection of methods that can be used to trigger and execute jobs. Each method has advantages and disadvantages.

Run jobs within 'on_render_complete' at the end of a page request

This is the broadly the same method as used by Nontab Scheduler. When concrete5 has finished sending a requested page to the browser, rather than just ending the page request, a scheduled job is requested using a separate web process.

  • Does not require JavaScript.
  • Immediate on page request.
  • Delays the final completion of a web request.
  • Triggered by search robots.
  • Will be the first method to run into server time limits when processing resources are marginal.

Run jobs from a tool triggered by an ajax callback from the client browser

If a job is due to run, a small snippet of jQuery is added to the end of a page. When the page has loaded, after a small delay this will run to make a tiny ajax callback from the browser. This triggers a tool on the server which double-checks the job schedule and the job is then requested using a separate web process.

  • Server processing is spread between processes, so is least likely to run into processing resource limits.
  • Requires web pages to load jQuery.
  • Will not trigger unless JavaScript is enabled.
  • Not triggered by search robots.
  • Leaves an XHR trace in a browser’s developer console.
  • Delays a job by the time taken for the ajax request to be started.

Run jobs from a tool triggered by an image loaded from the client browser

If a job is due to run, a small 1x1 gif image is added to the end of a page. When the browser loads this image triggers a tool on the server which double-checks the job schedule and the job is then requested using a separate web process in the same way as for the ajax callback method.

  • Server processing is spread between processes, so is least likely to run into processing resource limits.
  • Does not require JavaScript.
  • May not be triggered by search robots.
  • No delay in the browser (this can be good or bad!)
  • Leaves a trace in a browser’s developer console.
  • Delays completion of the page until the image is returned.

Page attribute

FlexJob Scheduler installs the page attribute "FlexJob Scheduler Disabled". When added to a page and set to true, FlexJob Scheduler will not piggy-back on to that page. This may be of use on home pages or pages that already consume considerable resources.

Advanced configuration options

Advanced options can be set by defining php constants in config/site.php. Unless you are a programmer, or are advised to set one of these options by an expert, it is best not to play with these. Setting them wrongly could result in scheduling becoming unstable.

Job Scheduling

  • FLEXJOB_SCHEDULER_CRON_CALC_GRANULARITY - the granularity with which the next job execution is calculated. Default is 300 seconds (5 minutes).
  • FLEXJOB_SCHEDULER_DEFAULT_REPEAT_INTERVAL - the approximate minimum separation between any jobs being run. Default is 60 seconds (1 minute).
  • FLEXJOB_SCHEDULER_DISABLE_TICK_PRE_TEST - if set to true, all page requests will check the job schedule. The default is false, so the job schedule check is only appended to a page when necessary. May be useful if caching of pages prevents job triggering. Default is false.
  • FLEXJOB_SCHEDULER_AJAX_CALLBACK_DELAY_MS - the delay of the ajax callback method. Default is 500 milliseconds (0.5 seconds).
  • FLEXJOB_ENABLE_LOG_JOB_OUTPUT - for diagnostics, if true all job output will be logged. Default is false.
  • FLEXJOB_TICK_SECONDS - the approximate minimum separation between a specific job being run. Default is 60 seconds.
  • FLEXJOB_TICK_START_HYSTERESIS_SECONDS - allow some flexibility in selecting the next job scheduled from the list in the database. Default is 60 seconds.

Dashboard page

In the FlexJob Scheduler dashboard page, look-ahead next run calculations are cached in the php session for optimum responsiveness. These options have no influence on the actual triggering of jobs.

  • FLEXJOB_SCHEDULER_NO_CRON_CALC_CACHE - set to true to disable the dashboard calculation cache.
  • FLEXJOB_SCHEDULER_CRON_CALC_CACHE_SIZE - make the cache larger or smaller. The default is 200 for each job.
  • FLEXJOB_SCHEDULER_WGET_COMMAND - can be used to override the wget command and parameters inserted in the "Export" tab.
  • FLEXJOB_SCHEDULER_ESCAPE_WGET_COMMAND_AMP - if set to true, ampersands within the URL shown in the "Export" tab will be escaped.

Export

If your site grows beyond FlexJob Scheduler and you graduate to using grownup real cron, the "Export" tab provides an export of cron settings to get you started.