Bash script help?
- From: elroyerni <davechunny@xxxxxxxxx>
- Date: Thu, 21 Feb 2008 12:43:16 -0800 (PST)
Hello -
I wrote this script to copy a file from my desktop to my nfs storage.
The problem is when i intentionally put the "sleep 3" line in my
script I expect it to send a email saying writing to the nfs took
longer than 2 seconds but it doesn't. It seems that i can't pass the
variable over? Do I need to re-write this in perl? Can anyone point me
to some literature or have some suggestions? Thanks!
#!/usr/bin/ksh
COMMAND=$(cp /u/dchun/file.txt /10.0.0.4/stuff/file.txt)
start_time=$(date +"%Y%m%d%H%M%S")
if [ "$COMMAND" != '' ]; then
message="NAS write failure TIME $(date +"%Y%m%d%H%M%S")"
echo "$message"| mail -s "ALERT: Can't write to NAS"
sam@xxxxxxxxx
sleep 3
stop_time=$(date +"%Y%m%d%H%M%S")
total_time=`expr $stop_time - $start_time`
elif [ "$total_time" -gt 2 ]; then
message="NAS write took too long $(date +"%Y%m%d%H%M%S")"
echo "$message"| mail -s "ALERT: Writing to NAS took longer
than 2 seconds" sam@xxxxxxxxx
else message="NAS OK"
fi
echo $(date +"%Y%m%d%H%M%S"):$message >> /u/dchun/cron/nfs_check.log
.
- Follow-Ups:
- Re: Bash script help?
- From: Cyrus Kriticos
- Re: Bash script help?
- From: Rob Silva
- Re: Bash script help?
- Prev by Date: Re: Get rid off last char on last line
- Next by Date: Re: Bash script help?
- Previous by thread: RSC description field
- Next by thread: Re: Bash script help?
- Index(es):
Relevant Pages
|