Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple script to run a command, write log and loop...girl in need!

Status
Not open for further replies.

WiccaChic

Technical User
Jan 21, 2004
179
US
Howdy all. Can someone give me a shell script skeleton I can use to do the following:

1. run command A
2. write to a log ONLY if command a errors
3. sleep for 3 seconds
4. loop back and do it again (and again, and again...)

I know, this is totally dumb I bet but I am not a unix genius.
 
while :
do
A
if [ $? -ne 0 ] ; then
echo "error running A" >> myLogFile.log
fi;
sleep 3;
done;

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Code:
#! /bin/sh
while true
do
    A || echo "Danger!" >>logfile
    sleep 3
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top