Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
> Problem Scheduling A Shell Script With "at"
ben631
post Mar 4 2005, 12:19 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 1
Joined: 4-March 05
Member No.: 4,728



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!
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
DS2K3
post Mar 4 2005, 05:36 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,284
Joined: 14-November 04
From: Southampton, Hampshire
Member No.: 4,165



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

D


--------------------
Fixed your problem? Let us know!
richard@linuxhelp.net

www.Gathr.co.uk Online Event Management
Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 17th October 2017 - 10:18 AM