Scheduling maintenance with scripts

This topic describes maintenance scripts and how to schedule them.

Maintenance Task Scheduler

The Maintenance Task Scheduler allows you to schedule scripts to run against local server configurations. The Maintenance Task Scheduler provides you with the ability to automate performance improvements on your database on a schedule that you choose. You can run scripts that will update query optimization statistics and online index rebuilding.

Here are some items to consider when using the Maintenance Task Scheduler:

  • You cannot modify scripts or add to the list of scripts.
  • If a script or folder containing the scripts is moved and there is a schedule for the script set, StarTeam Server will still attempt to run the script but it will log an error.
  • You can provide a Recurring schedule for your scripts. This gives you the flexibility to run scripts at different times. You can also run scripts ad hoc.
  • Script execution is logged in a file called execScript.log, located at the same location as the server log.
  • It is not possible to schedule scripts remotely through the Server Administration tool. This only works for local configurations.
  • You can define a new script schedule while the server configuration s running. The modification will be picked up after about 30 seconds.

Back to top

Assigning a schedule to a script

  1. On the Server Administration tool, select a local server configuration.
  2. Click Actions > Configure Maintenance Tasks. The Maintenance Task Scheduler dialog box opens.
  3. Select a script from the Scripts list.
  4. From the Frequency list, select Recurring.

    Note: To remove a schedule from a script, select Not Scheduled.

  5. Select the hours and minutes from the Time controls.
  6. Select on which days you would like to run the script.
  7. Click Save. Your schedule is saved and will execute at the specified date(s) and time(s).

Back to top

Maintenance scripts

The following scripts are available for the Maintenance Task Scheduler.

Note: The location of the script log is a subfolder named SchedulerLogs under the server log path.

Microsoft SQL Server

Script Name Description
starteam_sqlserver_create_sp_update_stats.sql Updates query optimization statistics. Updating statistics ensures that queries compile with up-to-date statistics. Can be run online or offline.
starteam_sqlserver_create_index_maintenance_script.sql Rebuilds indexes. Scheduling this script requires an edition of Microsoft SQL Server that supports online index rebuilding. If not supported but scheduled, there will be an exception in the log when running it.

Clustered indexes are rebuilt using the online option. To rebuild clustered indexes, the offline version should be executed whenever significant amounts of data is in the server.

It is always possible to run it offline by clicking Execute.

PostgreSQL

Script Name Description
starteam_postgres_create_compute_stats.sql Updates query optimization statistics. Updating statistics ensures that queries compile with up-to-date statistics. Can be run online or offline.
starteam_postgres_create_index_maintenance_script.sql Rebuilds indexes. Can be run online or offline.

Oracle

Script Name Description
starteam_oracle_create_compute_stats.sql Updates query optimization statistics. Updating statistics ensures that queries compile with up-to-date statistics. Can be run online or offline.
starteam_oracle_create_index_maintenance_script.sql

Rebuilds indexes. Scheduling this script requires an edition of Oracle database that supports online index rebuilding. (Currently Oracle Enterprise Edition only.) If not supported but scheduled, there will be an exception in the log when running it.

It is always possible to run it offline by clicking Execute.

Back to top

Maintenance Task Scheduler dialog box

Use the Maintenance Task Scheduler dialog box to schedule scripts to run against your local server configurations.

Scripts Provides a list of scripts that you can schedule to run.
Frequency Select how often you'd like the script to run.
Not Scheduled Default value for scripts without a schedule. Selecting this value will ensure that the script does not run. Other timing controls will be disabled.
Recurring This will cause the server to execute the script at the first available opportunity on or after the selected day of week and time of day. Selecting Recurring allows any number of days of the week to be selected. After execution, the schedule will remain in the Recurring state.
Time Select the hour and minutes from the lists.
Day of Week Check boxes Depending on the frequency you've selected, select the day(s) of the week that the script should execute.

In addition to the controls to set the schedule, you can use the following options:

Save Saves the schedule.
Execute Runs the script immediately. The Execute button only works for offline execution and can only be done when the server configuration is not running. Otherwise the option will be disabled in the dialog box.

Back to top