« The "oc4j log file" in SES | Main | Choosing which documents to index with a document service »

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 ' '

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mt/mt-tb.cgi/15091

About This Entry

This page contains a single entry from the blog posted on November 5, 2009 4:44 PM.

The previous post in this blog was The "oc4j log file" in SES.

The next post in this blog is Choosing which documents to index with a document service.

Many more can be found on the main index page or by looking through the archives.

Top Tags

Powered by
Movable Type and Oracle