Script scheduling problem using "at" command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script scheduling problem using "at" command
# 1  
Old 03-04-2005
Script scheduling problem using "at" command

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 commmand or script while using the "at" command. I know I can put everything in a file and make at use that file but I would prefer not to... 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!
# 2  
Old 03-07-2005
maybe you want like this:
Code:
objIp=127.0.0.1
/usr/sbin/ping $objIp 5 >/dev/null && echo "$objIp is alive" || { echo "$objIp isn't exists"; exit 0; }

# 3  
Old 03-08-2005
echo "$script prealert $2" | at now + 2 minute
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

Scheduling scripts with "at" command

Hi All , I need to create a scheduling capability on one of Linux boxes so that i could some 6 scripts back to back after a gap a given time difference . To run script1 :-- my test1.sh for 3 hrs , followed by 2nd script ,mytest2.sh for 10 hrs , then mystest3.sh for 2 hrs , then... (3 Replies)
Discussion started by: Anamica
3 Replies

5. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

9. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

10. UNIX for Dummies Questions & Answers

Unix "at" / "Cron" Command New Problem...Need help

Hi All, I am trying to schedule a one time job using the at command with the help of shell script for my project. The shell script should take a parameter as a command line argument from the at command itself. Is it possible to take a command line parameter for a shell script in the command... (3 Replies)
Discussion started by: Mohanraj
3 Replies
Login or Register to Ask a Question