Launching SES schedules from the command line

The scheduler within the SES admin system has some limitations. For example you can't ask a schedule to run every weekday but not at weekends.

For this reason some users prefer to use a scheduler such as "cron" instead.

There is a utility called "searchadminctl" which can be used to launch schedules, but this will not "queue" schedules - if the schedule is already running then searchadminctl will just exit.

The shell script below checks the status of the schedule, and if it is in "launching" or "executing" status it will wait until it completes before restarting it.

NB to check the schedule, it looks in an internal table. It is possible, though unlikely, that this table name or layout could change in a future version.

#!/bin/bash

# Shell script to launch a schedule. If the schedule is already running,
# wait for it to complete.

# Note: if you get an error "./launch.sh: line 29: [: too many arguments"
# it probably means you have the schedule name wrong

# SET THESE NEXT FOUR VARIABLES TO SUIT YOUR ENVIRONMENT

# File to set up environment variables ORACLE_HOME, ORACLE_SID and PATH
export ENV_FILE=/home/raford/ses.env

# SES Admin Password
export SES_PWD=sespassword

# Name of Schedule to launch
export SCHEDULE_NAME="My Schedule Name"

# Delay time to wait between tests if schedule is running (seconds)
export WAIT_TIME=60

. $ENV_FILE

export crawlstat=EXECUTING
export firsttime=TRUE

until [ $crawlstat != EXECUTING -a $crawlstat != LAUNCHING ] ; do

if [ $firsttime != TRUE ] ; then
  echo Sleeping...
  sleep $WAIT_TIME
fi
export firsttime=FALSE

sqlplus -s eqsys/$SES_PWD > /tmp/sql$$ <<EOF
set feedback off
set heading off
exec eq_adm.use_instance(1)
select cs_state from eq\$crawler_sched where cs_name = '$SCHEDULE_NAME';
quit
EOF

export crawlstat=`tail -1 /tmp/sql$$`

echo status is $crawlstat

done

echo Launching Schedule...

searchadminctl -p $SES_PWD <<EOF
schedule -start "$SCHEDULE_NAME"
quit
EOF

# tidy up
rm /tmp/sql$$
echo ' '
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

bocadmin_ww

Search

Categories
Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today