Yep, sure. As for configuring cron - I think someone else has already posted
this.

My preferred option is to use wget:

wget --non-verbose --output-document=- http://www.host.tld/page.ext $1
$2>/dev/null

I use the following bash script - which allows notification if a process
fails a configurable number of times - it will then send an email to the
address in the script. I normally have this script at
/opt/net/openAction/wwwCallURL/wwwCallURL - but you can put it wherever you
wan. To use the script you will need to change the log directory and error
count file to valid directories (and possibly create directories) and update
the email address to your address.

To run the script use, typically from cron:

        ....path..../wwwCallURL http://www.host.tld/page.ext

The default behaviour is if it fails 5 times in succession it will send an
email to the email address listed in errcntemailnotify - but you could also
run other commands at this point to try to rectify the situation, e.g. we
have scripts that monitor tomcat and send an email and issue a restart if it
fails 3 times in a row - this script is run every 90 seconds.

Hope that helps,

Hue.

# wwwCallURL: Calls a URL on a web server to initiate
#             a server process and facilitates running
#             an action in the event of configurable
#             number of failures.
#             This script needs to be run with sufficient
#             privileges to write to log directories
#             and to perform the specified custom action
#             and typically on the server being accessed
#             as this then allows filtering the server
#             processes only on localhost/127.0.0.1
#             for improved security.
# FHS: typically install under /opt/net/openAction/wwwCallURL/
#      and logs in /var/opt/net/openAction/wwwCallURL/
# Developed under Debian GNU/Linux 3.0
# Language: bash
# Depends: wget, mailx
# Copyright 2000-2002 Hue Holleran <[EMAIL PROTECTED]>
# This is free software; see the GNU General Public License version 2
# or later for copying conditions.  There is NO warranty.

############################################################################
###
# EDIT THIS SECTION TO CHANGE LOG FILE LOCATIONS
#
############################################################################
###
# define logs directory and files
logfile="/var/opt/net/openAction/wwwCallURL/history.log"
errcntfile="/var/opt/net/openAction/wwwCallURL/errcnt.log"
# END SECTION

############################################################################
###
# EDIT THIS SECTION TO CHANGE ERROR THRESHOLD AND ACTION
#
############################################################################
###
# define error count and action to be performed on error count
errcntmax=5
errcntemailnotify="[EMAIL PROTECTED]"
errcntreachedaction="echo '' | mailx -s '$0: Process has failed: max of
$errcntmax errors reached.' $errcntemailnotify"
# END SECTION

# output program name, version and copy info
echo -e "$0 1.02 (06-Oct-2002)"
echo -e "(c) 2002 Hue Holleran <[EMAIL PROTECTED]>"
echo -e "Calls URL on web server."

# define usage information
usage="Usage: $0 URL\n"

# ensure a URL has been passed - if not exit with level 1
if [ "$1" = "" ] ; then
    echo -e $usage 1>&2 ; exit 1 ;
fi

# get the return value to variable 'result'
result=$(wget --non-verbose --output-document=- $1 2>/dev/null)
exitcode=$?

# check return value
if [ $exitcode -ne "0" ] ; then
    # if there was an error - attempt to repeat
    # this time append stderr to input
    resultrepeat=$(wget --verbose --output-document=- $1 2>&1)
    exitcode=$?
    # check return value (it may now be ok)
    if [ $exitcode -eq "0" ] ; then
       result="success... but on retry"
    else
       result=$resultrepeat
    fi
fi

# determine if result was ultimately successful
echo -en "$(date --utc +'%a %d-%b-%Y %X') " >> $logfile
if [ $exitcode -eq "0" ] ; then
    # Result was successful - write to log
    echo -e "OK $result" >> $logfile
    echo -e "OK: $result\n"
    # Reset cumulative error count to 0
    echo "0" > $errcntfile
    # Exit script with no error
    exit 0
else
    # Result was NOT successful - write to log
    echo -e "ERROR $result" >> $logfile
    echo -e "** ERROR **:\n$result\n"
    # Determine number of prior errors
    errcnt=$(cat $errcntfile)
    # Increment error counter and write to error counter
    echo $((++errcnt)) > $errcntfile
    # See if error count has reached max threshold
    if [ $errcnt -ge $errcntmax ] ; then
         # Reset cumulative error count to 0
         # NB: do this before running command to
         #     avoid race condition that may arise
         #     should repair command abend the script.
         echo "0" > $errcntfile
         # Run command on number of errors threshold reached
         result=$($errcntreachedaction)
         echo -en "$(date --utc +'%a %d-%b-%Y %X') " >> $logfile
         echo -e "ERROR COUNT AT MAXIMUM $errcntmax: $result\n"
    fi
    # Exit script with error level 2
    exit 2
fi



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 01 September 2003 11:07
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: RE: [OT] Scheduling
>
>
>
> Hi,
> Can you throw some light on the Unix "cron". I have Weblogic running on
> Unix. so, i guess i can use this solution.
>
> thanks
> -raj
>
>
>
>
>
>
>
>                       "Hue Holleran"
>
>                       <[EMAIL PROTECTED]        To:
> "Struts Users Mailing List" <[EMAIL PROTECTED]>
>
>                       Action.net>                   cc:
>
>                                                     Subject:  RE:
> [OT] Scheduling
>                       01/09/2003 03:26 PM
>
>                       Please respond to
>
>                       "Struts Users Mailing
>
>                       List"
>
>
>
>
>
>
>
>
>
> Well, possibly not an elegant answer but...
>
> 1) Under *nix we've done this with "cron" and a "bash script" that invokes
> "wget" to launch a servlet process.
> 2) Under Windows we've used a VBS script via
> "at"/"winat"/"Scheduled Tasks"
> and "Microsoft.XMLHTTPRequest" to initiate a HTTP connection to launch a
> servlet process.
>
> Both have been very reliable (in fact both are in very widespread use on
> several servers) - and this is nice as it does not require any 3rd party
> components.
>
> If this is along the lines of what you're trying to do let me know and I
> can
> post some code. As regards Weblogic, there's possibly a more elegant
> solution, but sorry don't use it - so don't know.
>
> Hue.
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Sent: 01 September 2003 06:37
> > To: [EMAIL PROTECTED]
> > Subject: [OT] Scheduling
> >
> >
> > Hi All,
> > What would be the best implementation for scheduling a job in
> > Weblogic/J2EE
> > environment ?
> >
> >
> > thanks
> > -raj
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ---
> > Incoming mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003
> >
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to