Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ Problem Scheduling A Shell Script With "at"

Posted by: ben631 Mar 4 2005, 12:19 PM

Hello!

I'm writing a shell script that will monitor if a server is up or down.

I would like to use the command "at" inside of my script to reschedule the script to run in 2 minutes but I can't pass parameters to my script and this is my problem...

This is the idea behind the script:

1. The script run in "normal mode" and check if the server is up. If the server is not responding, the script go to step 2.

2. Schedule itself to run in two minutes in "prealert mode"

3. When running in "prealert mode", the script check if the server is still not responding and if not, send a alert to the network administrator.


Does anybody know how to pass parameters to a commmandscript while using the "at" command. Or any suggestion?

Syntax example to execute the script:

./test_ping prealert server1.test.com

Here is a sample of my script:

#!/bin/bash
#Script to test network connectivity
#By Benoit Charbonneau
#March 4th 2005
#Parameters ex.: test_ping mode(normal|prealert) server

log="../monitoring.log"
date=$(date)
path=$(pwd)
script=$path/test_ping

ping -c1 -w2 $2 > /dev/null
error=$?

if [ $1 = "normal" ]; then
if [ $erreur != 0 ] ; then
at -f "$script prealert $2" now + 2 minute
# My problem is here
echo $date $2 ping error - A prealert has been open >> $log
else
echo $date $2 ping ok >> $log
fi
fi

if [ $1 = "prealert" ]; then

...


Sorry if i'm not clear enought. English is not my first language...

Thank you for your help!

Posted by: DS2K3 Mar 4 2005, 05:36 PM

You could set an envvironment variable that the script looks for when it is run, or maybe write to a file in /tmp

D

Posted by: docmur Mar 5 2005, 10:21 PM

The router table goes in 60 90 120 seconds you have to pass the values of 1 minute then 90 second in before the ping can access the ARP tables in the router

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)