Scheduled jobs
- Overview
- Create scheduled job
- Update existing scheduled job
- Delete scheduled job
- Run a scheduled job manually
- Custom actions scheduled job
Overview
Scheduled jobs are automated tasks, performed by the system through server commands. These "jobs" can be scheduled to run at specific intervals (hourly, daily, weekly, monthly...), but can be also be ran manually through the ERP system.
Scheduled jobs are tasks, that the system can perform on it's own, such as creating announcements, indexing data...
Create scheduled job
This task should be done only by developer administrators.
To create a new scheduled job, you must click on the "+" icon on the top right corner. You will be redirected to the "Create new scheduled job form"
Scheduled jobs are commands, that are run in the server's command line. Since only administrators with access to the code base can see all available commands, scheduled jobs should be added only by those users.
Once a unique name and job's corresponding command are inputted, the "Cron inverval" must be defined. This attribute defines the job's regular schedule (when it will run). A job can be run on intervals, ranging from every few minutes to running once a year.
The "Last job success" attribute does not need to be set when creating a new scheduled job. This attribute is updated every time the scheduled job runs and shows, if the last run of the scheduled job was successful.
A job has to be enabled to run on it's regular intervals. If we want to notify the development team of a failed scheduled job, we must enable the "Notify on fail" option.
Command parameters
You can pass parameters to any commands with space delimiter. This parameter (argument) will be used in both, a scheduled or on-demand run. Example, where we pass callClass
parameter in the command
field:
scheduled-job:run-action callClass=App\Containers\ExternalApplication\Actions\BusinessCentral\SyncExpenseEventsFromBcAction
Update existing scheduled job
Existing scheduled jobs should only be updated by users with access to the code base.
Viable updates for scheduled jobs are changing description, enabling/disabling the job, it's email notification on failed run, or changing the "Cron interval", that specifies when the job runs.
Delete scheduled job
Scheduled jobs should ONLY be deleted by administrators with access to the code base.
If a scheduled job is no longer needed, rather than deleting it, disable it, leaving a chance for it to be reactivated if ever needed.
Run a scheduled job manually
Some scheduled jobs can be run manually from the ERP, if a need for that ever arises. Manual runs should not be the norm, as scheduled jobs are configured to auto-run atregular intervals.
To run a scheduled job, go to scheduled job's edit page and look for the "Run scheduled job now" button in the top right corner of the page.
On clicking it, the scheduled job will perform a manual run. Once the manual run is completed, it will be displayed on the list of last 30 runs logs with the message "on demand run".
Custom actions scheduled job
Scheduled jobs can invoke on existing commands from inside of ERP code.
To fix this there is a command, that receives a parameter called "callClass
", that can call any Action or Task in ERP.
Sample command code:scheduled-job:run-action callClass=App\Containers\ExternalApplication\Actions\BusinessCentral\SyncExpenseEventsFromBcAction
It also takes an additional argument, that can be passed to it if want/needed: additionalArgument