Creating a task
You can create a Scheduler task to perform a specific action at specific times.
Before you begin
About this task
Procedure
- Include values for the following columns:
- Optional: Change the default values for the
following columns:
- tk_start_time: The default start time is 8:00:00. For a startup task, set the start time to NULL.
- tk_stop_time: The default stop time is 19:00:00. For a startup task, set the stop time to NULL.
- tk_frequency: The default frequency once a day. For a startup task, set the frequency to NULL.
- tk_group: The default group is MISC.
- tk_monday through tk_sunday: The default is to run every day.
Results
Example
The following task uses the SQL administration API to take a checkpoint every two minutes between the hours of 8:00 A.M. and 7:00 P.M. on Mondays, Wednesdays, and Fridays.
INSERT INTO ph_task
( tk_name,
tk_description,
tk_type,
tk_group,
tk_execute,
tk_start_time,
tk_stop_time,
tk_frequency,
tk_Monday,
tk_Tuesday,
tk_Wednesday,
tk_Thursday,
tk_Friday,
tk_Saturday,
tk_Sunday)
VALUES
( "Example Checkpoint",
"Example to do a checkpoint every 2 minutes.",
"TASK",
"EXAMPLES",
"EXECUTE FUNCTION admin('checkpoint')",
DATETIME(08:00:00) HOUR TO SECOND,
DATETIME(19:00:00) HOUR TO SECOND,
INTERVAL ( 2 ) MINUTE TO MINUTE,
't',
'f',
't',
'f',
't',
'f',
'f');
The following example shows the code for
a task that runs once a day at 2:00 A.M. to ensure that the command_history table
contains only recent data. In this example, the definition of recent
data is stored in a Command History Interval column in the ph_threshold table.
INSERT INTO ph_task
(
tk_name,
tk_group,
tk_description,
tk_type,
tk_execute,
tk_start_time,
tk_frequency
)
VALUES
(
"mon_command_history",
"TABLES",
"Monitor how much data is kept in the command history table",
"TASK",
"delete from command_history where cmd_exec_time < (
select current - value::INTERVAL DAY to SECOND
from ph_threshold
where name = 'COMMAND HISTORY INTERVAL' ) ",
"2:00:00",
"1 0:00:00"
);