Automating Host Group Management > Scheduling Utilities To Run Automatically
  
Version 10.1.01
Scheduling Utilities To Run Automatically
The utilities can be run on a one-time basis, or scheduled to run every day to automatically keep your hosts and host groups up to date. Scheduling can be accomplished by creating an Oracle job. APTARE StorageConsole already makes use of Oracle jobs to run many background tasks such as purging old data and rebuilding indices.
The sample SQL file in Example—Scheduling Utilities to Run Automatically sets up an Oracle job to run every day at 5:00 a.m. and call the moveOrCopyClients utility to move clients from one folder to another. This example can be used as a template for other automatic jobs you need to set up. Simply customize the text in bold for your particular requirements.
To see the Oracle jobs that are automatically configured as part of a new install, review the following files:
<database_home>/stored_procedures/setup_base_jobs.plb
<database_home>/stored_procedures/nbu/setup_nbu_jobs.sql
<database_home>/stored_procedures/tsm/setup_tsm_jobs.plb
<database_home>/stored_procedures/tsm/setup_leg_jobs.plb
Where database_home is /opt/aptare/database for Linux servers and C:\opt\oracle\database for Windows servers.
Example—Scheduling Utilities to Run Automatically
In order to execute the following sample SQL file, as user aptare on a Linux system or on a Windows system as an Administrator who is a member of the ORA_DBA group execute the following:
 
sqlplus portal/portal_password @setup_ora_job.sql
 
The following example uses two methods:
moveOracleClients
The name you want to assign to this job you are defining.
MoveOrCopyClients
The utility you are calling along with the parameters you are passing.
Note: The parameters passed to the moveOrCopyClients method which must be quoted actually have two single quotes. The two single quotes is the standard Oracle syntax to incorporate a literal quote within an already quoted string.
 
Sample .sql file (setup_ora_job.sql) to set up an automatic job
SET SERVEROUTPUT ON
SET ECHO OFF
DECLARE
jobNo user_jobs.job%TYPE := NULL;
BEGIN
----------------------------------------------------------------------
-- Move new clients whose server name ends with 'ORA' into the 'database' host group
-- Frequency: Every day at 5am (Portal Time)
----------------------------------------------------------------------
jobNo := dba_package.getDatabaseJobID('moveOracleClients');
IF (jobNo IS NOT NULL AND jobNo != 0) THEN
DBMS_OUTPUT.put_line('moveOracleClients exists and will first be removed before adding a new version');
DBMS_JOB.REMOVE(jobNo);
END IF;
DBMS_JOB.SUBMIT(
job => jobNo,
what => 'server_mgmt_pkg.moveOrCopyClients(''/Aptare'',''/Aptare/database'',''*ORA'', 1);', -- What to run
next_date => SYSDATE + (5/24), -- First run is 5am server time
interval => 'TRUNC(SYSDATE+1,''DD'') + (5/24)'); -- Next run is 5am each subsequent day
DBMS_OUTPUT.put_line('moveOracleClients job set to run at 5am every day');
COMMIT;
END;
 
/
quit;