Job & Schedule management
Like most DBMSes, Lyftron supports used-defined recurrent task called a job. To define a job, a schedule should be defined first. Lyftron mimics job management implementation after Microsoft SQL Server. It means user can define job using GUI or using SQL.
Schedules can be found under Administer -> Schedule management.
The screen supports searching. A new schedule can be defined by clicking the Add schedule button.
The following schedule types apply:
The linked job will be run once on the given day/time.
Scheduled tasks will be run once or more than once per day on a given time.
Recurs every N days means a given tasks will be run every n days.
Daily frequency can be set a specific time of day or a recur value (e.g. Every N minutes) with additional daily time bounds.
Start date and optional End date can be used to globally limit the schedule time span.
This schedule is used to configure tasks to be run on particular days of the week.
It behaves the same way as the daily schedule except for multiple days of the week can be selected.
To run a job on given day of the month this option is the right choice.
Again, either a specific time or time-bound recurrence can be selected.
Jobs can be found under Administer -> Job management.
The screen supports searching. A new job can be defined by clicking the Add job button or using sql.
Input a name and description and click Create. This will cause the job to be saved and appear on the list.
Click the job on the list to access the details pane. In the bottom, you will find 3 sub-blades that allow tuning the job details.
The Start job buttons allow running the job at any time.
Clicking Steps brings up the job step configuration screen. A single job can consist of any number of step. A new step can be defined by clicking the Add step button.
The following table summarizes the parameters:
|Step Id||Auto-generated Id of the step, used for jumps (see below).|
|Step Name||A user-friendly name of the step.|
|Command||An arbitrary SQL to be run on the target database.|
|On success action||The action to be performed when the step succeeds. Choosing Go to specified step allows to set the Id of the target jump step.||Go to next step|
|On fail action||The action to be performed when the step fails. Choosing Go to specified step allows to set the Id of the target jump step.||Quit with failure|
|Database name||The target database that this step will run on.|
Clicking Save will save the step and return to the step list.
Past execution attempts of a given job can be found under Execution history
The Schedules section allows to link an arbitrary number of Scheduler to the given job:
This can be achieved by clicking the Add schedule button and picking the proper positions.
Job management using SQL
A SQL Server compatible stored procedures can be used to manage jobs.
In the following example, we: * define a job, * add a custom task to it, * define a schedule, * attach the schedule to the job, * execute the job explicitly.
exec sp_add_job @job_name = 'myjob' exec sp_add_jobstep @job_name = 'myjob', @step_name = 'step1', @command = 'select 1'
exec sp_add_schedule @schedule_name = 'every_10_seconds', @freq_type = 4, -- daily @freq_subday_type = 2, -- subday interval seconds @freq_subday_interval = 10 -- every 10 seconds exec sp_attach_schedule @job_name = 'myjob', @schedule_name = 'every_10_seconds'
exec sp_start_job @job_name = 'myjob' -- execute job once