sfDoctrineCronManagerPlugin
0.9.3beta
for sf 1.4sf 1.3 and Doctrine
MIT
Allows users to administer cron jobs from a backend interface. Useful for users with limited admin access to the server. Jobs can be added, deleted, or run at any time for testing or other purposes.
In addition to standard cron functionality, this plugin allows the user to suppress the execution of a cron job if the current one minute load average exceeds a value set by the user. This can prevent system resource-intensive tasks from running, allowing them to be delayed until server load is better able to manage.
Developers
| Name |
Status |
Email |
Bob Stremel |
lead |
moc.liamg <<ta>> lemerts.bob
|
License
Copyright (c) 2011 Bob Stremel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Releases for sf 1.4
| Version |
License |
API |
Released |
|
0.9.7beta
|
MIT license |
0.9.7beta
|
20/02/2012 |
|
0.9.6beta
|
MIT license |
0.9.6beta
|
19/02/2012 |
|
0.9.5beta
|
MIT license |
0.9.5beta
|
28/04/2011 |
|
0.9.4beta
|
MIT license |
0.9.4beta
|
21/03/2011 |
|
0.9.3beta
|
MIT license |
0.9.3beta
|
26/02/2011 |
|
0.9.2beta
|
MIT license |
0.9.2beta
|
26/02/2011 |
|
0.9.1beta
|
MIT license |
0.9.1beta
|
25/02/2011 |
|
0.9.0beta
|
MIT license |
0.9.0beta
|
21/01/2011 |
Releases for sf 1.3
| Version |
License |
API |
Released |
|
0.9.7beta
|
MIT license |
0.9.7beta
|
20/02/2012 |
|
0.9.6beta
|
MIT license |
0.9.6beta
|
19/02/2012 |
|
0.9.5beta
|
MIT license |
0.9.5beta
|
28/04/2011 |
|
0.9.4beta
|
MIT license |
0.9.4beta
|
21/03/2011 |
|
0.9.3beta
|
MIT license |
0.9.3beta
|
26/02/2011 |
|
0.9.2beta
|
MIT license |
0.9.2beta
|
26/02/2011 |
|
0.9.1beta
|
MIT license |
0.9.1beta
|
25/02/2011 |
|
0.9.0beta
|
MIT license |
0.9.0beta
|
21/01/2011 |
Changelog for release 0.9.3 - 26/02/2011
- Added additional testing in response to bugs, located and fixed bugs
Other releases
Release 0.9.7 - 20/02/2012
- Fixed display of predefined schedules (@daily instead of 0 0 * * *)
Release 0.9.6 - 19/02/2012
- Added ability to parse days of the week in text format (Sun - Sat)
- Added ability to parse days of the month in text format (Jan - Dec)
Release 0.9.5 - 28/04/2011
- Fixed bug where next run date was not correctly calculated.
* Marked job as run before starting it, so that it cannot be picked up again if the job takes longer than one minute to run and the job is configured to Run if Missed.
Release 0.9.4 - 21/03/2011
- Added missing files to release package
Release 0.9.3 - 26/02/2011
- Added additional testing in response to bugs, located and fixed bugs
Release 0.9.2 - 26/02/2011
- Fixed incorrect unit test bootstrap path
Release 0.9.1 - 25/02/2011
- Added the ability to use the cron slash shorthand notation (ex. 0-59/5 or */5, every 5 minutes)
Release 0.9.0 - 21/01/2011
sfDoctrineCronManager plugin
The sfDoctrineCronManagerPlugin provides backend administration capabilities for
cron jobs. This is useful if developers have limited access to the production server
but still need to schedule, modify, or run cron jobs without server access.
Installation
Install the plugin (via a package)
symfony plugin:install sfDoctrineCronManagerPlugin
Install the plugin (via a Subversion checkout)
svn co http//svn.symfony-project.com/plugins/sfDoctrineCronManagerPlugin/trunk plugins/sfDoctrineCronManagerPlugin
Activate the plugin in the config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins(array(
'sfDoctrinePlugin',
'sfDoctrineCronManagerPlugin',
'...'
));
}
}
Rebuild your model
symfony doctrine:build-model
symfony doctrine:build-sql
Update you database tables by starting from scratch (it will delete all
the existing tables, then re-create them):
symfony doctrine:insert-sql
or do everything with one command
symfony doctrine-build-all-reload frontend
or you can just create the new tables by using the generated SQL
statements in data/sql/schema.sql for the sf_cron_manager_job table.
As another alternative, you can run
symfony doctrine:generate-migrations-diff
and use the resulting file to migrate an existing implementation.
Enable the module in the settings.yml file for your backend application:
all:
.settings:
enabled_modules: [default, ..., sfCronManager]
Clear your cache
symfony cc
Finally, you must configure your server to call the new plugin each minute. This will run all other jobs in turn. To configure this, add the following to your crontab:
* * * * * php /path/to/symfony/project/symfony cron:go
Features
Configure cron jobs in a familiar manner, using standard cron syntax
Take advantage of additional features not found in the cron package, described below
Feature: Load Limits
Certain jobs are processor-intensive and can drag a server down. If cron blindly
continues to run these processes it has the potential to take the server down, or
make the user experience very poor. The ability to suppress a cron job based on the
current server load is an improvement beyond the capabilities of cron.
Set the limit as necessary within the job interface. This limit is numerical and
corresponds to a one-minute load given by the linux uptime command. If this limit is exceeded when
the job is due to run, it will be suppressed. Obviously, this could lead to the job
continually being suppressed and never running as a result. For this reason, we can set
a limit for how many times the job is suppressed.
Feature: Maximum Suppressed Runs
This can be used to limit the number of consecutive times a job is suppressed. This is set,
by default, to a value of three. If the job is suppressed more than three times, the job will be run
regardless, and the current suppressed run counter will be reset to zero. This ensures that the job
cannot be permanently suppressed, but allows us to schedule non-critical jobs to off-peak periods.
Feature: Run If Missed
If the server goes down for an extended period of time, certain jobs may not run. Rather
than look through the cron commands and calculate which jobs need to be run by hand, this
setting will ensure that any job that was missed will be run automatically when the server
is again running normally. This can be done because each time a job runs, the next run time
is calculated and stored. Checking the next run time of each job allows this feature to
run missed jobs.
Schedule a cron job
Open your project's backend and visit /sfCronManager, then click the New link.
Provide the following information:
- Title: A descriptive title for the job
- Active: A flag that turns the job on or off
- Schedule: The standard, cron notation schedule for the job. For details on the cron format, go here
- Command: The command to be run when the conditions of the schedule are met. This can be a unix command, a call to a symfony task, etc.
- Load Limit: Allows the job to be suppressed if the one-minute load on the server exceeds this threshold.
- Max. Suppressed Runs: If the run has been suppressed based on server load, this limit can be set to ignore that and force the job to run.
- Run if missed: If the job is missed due to server downtime, this flag can be set so that the job will run if it was missed for any reason.
If the job will run at a future date, you may click the Run Now option in the Actions column when looking at the jobs list. This will allow you to test.
Tasks
This plugin provides a task to review all jobs and run those that are due based on the current time. The cron:go task, configured
during installation, will run all jobs. If you happen to know the ID of the job you wish to run, which is simply the database ID of the
job record, you may run it directly using the command:
symfony cron:go [task_id]
To Do
- The parser only accepts numerical cron input, ex. 0,30 * 1-5/2 * 3. A day of the week of
fri, while valid cron syntax, will not work.