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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP USING WHILE...

Status
Not open for further replies.

johngiggs

Technical User
Oct 30, 2002
492
US
I am attempting to make it so my script only runs Monday through Friday from 7:00 AM until 6:00 PM, but the test below doesn't seem to work. Any help would be greatly appreciated.

#!/bin/sh -f

DAY=`date +%a`
TIME=`date +%H%M`

while [ $DAY = Mon -o Tue -o Wed -o Thu -o Fri ] && [ $TIME -gt 0700 -a $TIME -lt 1800 ] ;

do

......

Thanks,

John
 
The syntax of your test is probably very bad, and testing that many conditions is pretty ugly.

Does this run daemon-like, or is it started by cron?
 
It's not in cron. I just wanted to run it in the background with nohup.

Thanks,

John
 
Need to add done after your commands

while [ condition ]
do
commands
done
 
I guess you could use %u Weekday as a one-digit decimal number [1-7 (Monday-Sunday)].

DAY=`date +%u`
TIME=`date +%H%M`

while [ $DAY -lt 6 -a $TIME -gt 0700 -a $TIME -lt 1800 ]
do
......
done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top