Use create schedule to create a schedule to execute shell commands at a time you specify.
create schedule sched_name as ‘sched_time’ [set {on | off}] for exec ‘command’
sched_name – the name of the schedule you provide, which:
Must conform to the rules for identifiers
Must be unique
Can be 1 – 30 bytes long
‘sched_time’ – specifies the time and day to execute ‘command’. Provide the day and time in the restricted UNIX cron style with a single space separating the time and date parameters:
[mm] [HH] [DOM] [MON] [DOW]
The time and date parameters are:
Parameter |
Description |
Values |
---|---|---|
mm |
Minutes past the hour |
0 – 59. Use “*” to include all legal values. |
HH |
Hour in 24-hour notation |
0 – 23. Use “*” to include all legal values. |
DOM |
Day of the month |
1 – 31. Use “*” to include all days of the month. |
MON |
Month of the year |
1 – 12. Use “*” to include all months of the year. |
DOW |
Day of the week |
0 – 6 with 0=Sunday. Use “*” to include all days of the week. |
Use an asterisk “*” to specify all valid values. For example, “17 20 * * *” represents a daily schedule at 8:17 p.m.
Use a comma “,” to separate values that are not part of a range. For example, “17 20 1,15 * *” represents 8:17 p.m. on the 1st and 15th of every month, where 1 and 15 are the values for the DOM parameter.
Use a hyphen “-” between two values to specify a range of values, inclusive of the two values. For example, “17 20 * * 1-5” represents 8:17 p.m. from Monday to Friday where “1-5” are the range of values for the DOW parameter.
For the DOM, MON, or DOW parameters, you can specify the day using both the DOM and DOW parameters. Replication Server follows all schedules you specify in the string. For example, “0 12 16 * 1” represents 12:00 p.m.every Monday and 12:00 p.m. on the 16th of every month.
set {on | off} – enables or disables the schedule when you create it. By default, the schedule is on.
‘command’ – specifies the shell command, such as scripts, executables, or batch files to execute at the specified schedule.
Shell commands:
Must be in $SYBASE/$SYBASE_REP/sched for UNIX or %SYBASE%\%SYBASE_REP%\sched for Windows
Can include parameters delimited with a space within the shell command.
In Windows, create schedule executes the command specified in the last parameter within the shell command or batch file. You must also include stdout to a file in the create schedule command line.
In shell command names, you:
Can use only ASCII alphanumeric characters, such as A – Z, a – z, and 0 – 9
Can use the “.”, “-”, and “_” characters
Cannot use the “\” and “/” characters
Must include the .bat suffix if you are executing on Windows. For example, the name should be suspend_conn.bat on Windows and suspend_conn.sh on UNIX.
Example 1 Create “schedule1” in Windows that suspends the connection to the pubs2 database in the SYDNEY_DS data server at 12:00 p.m.every Monday and 12:00 p.m. on the 16th of every month:
Create a text file, such as sql.txt that contains the actual Replication Server command line that you want to schedule. For example, sql.txt can contain
suspend connection to SYDNEY_DS.pubs2 go
Create a batch file, such as suspend_conn.bat in Windows that contains isql and relevant parameters to run the command line in sql.txt. For example, suspend_conn.bat can contain:
%SYBASE\OCS-15_0\bin\isql.exe -Usa -P -S SYDNEY_DS -I %SYBASE%\sql.ini -i %SYBASE%\REP-15_5\sched\sql.txt
Create the schedule, “schedule1”:
create schedule schedule1 as ‘0 12 16 * 1’ for exec ‘test.bat > c:\temp\test.out’ go
Example 2 Create “schedule2” to execute the suspend_conn.sh script in UNIX that suspends the connection to the pubs2 database in the SYDNEY_DS data server every day at 8:17p.m.:
create schedule schedule2 as ‘17 20 * * *’ for exec ‘suspend_conn.sh’
Example 3 Create “schedule3” to execute the resume_conn.sh script that resumes the connection to the pubs2 database in the SYDNEY_DS data server every day at 7:15 AM:
create schedule schedule2 as '15 7 * * *' for exec ‘resume_conn.sh’