![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem using sleep command | lione.heart | Shell Programming and Scripting | 7 | 10-28-2007 04:06 AM |
| sleep command | leewar | UNIX for Dummies Questions & Answers | 3 | 09-11-2007 12:01 AM |
| How can I get a command to sleep < 1 second? | mattd | UNIX for Dummies Questions & Answers | 1 | 08-04-2003 12:35 PM |
| passing parameters to sleep command | nagaraju_svs | UNIX for Dummies Questions & Answers | 1 | 07-16-2003 09:17 AM |
| Sleep under one second | Scoogie | Shell Programming and Scripting | 5 | 08-14-2002 08:10 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Sleep Command
I am in need of some help; think I have confused myself.
Here is the issue I am faced with. The script log file was fine, the nohup.out file has tens of thousands of lines like illegal use of sleep: sleep seconds So I assume there is something with the seconds calculation in the script belwo; also checked date function on unix, didn't find anything wrong. Code:
let target_hour=0730
if ( $# <= 2 ) then
echo Usage: schedule1 [shell file] "&"
exit 1
else
k=1
while :
do
current_date=`date +%w`
current_hour=`date +%H%M`
second=`date +%S`
var1=`date +%H`
var1_min=`date +%M`
var2=${target_hour%??}
var2_min=${target_hour#??}
if [[ current_date -gt -1 ]]
then
if [[ current_hour -lt target_hour ]]
then
hours=$((((var2-var1))*3600))
minutes=$((((var2_min - var1_min))*60))
if [[ var2 -gt var1 ]]
then
sleep $((hours+minutes-second))
elif [[ var2 -eq var1 ]]
then
sleep $((minutes-second))
fi
k=1
elif [[ current_hour -gt target_hour ]]
then
hours=$((((23-var1))*3600))
minutes=$((((60-var1_min))*60))
sleep $((hours+minutes-second))
k=0
elif [[ current_hour -eq target_hour ]] && [[ k -eq 1 ]]
then
echo `date +%Y%m%d`
$1
k=0
elif [[ current_hour -eq 1000 ]] && [[ k -eq 0 ]]
then
hours=$((((23-var1))*3600))
minutes=$((((60-var1_min))*60))
sleep $((hours+minutes-second))
k=0
fi
else
hours=$((((23-var1))*3600))
minutes=$((((60-var1_min))*60))
sleep $((hours+minutes-second))
k=1
fi
done
fi
Thanks, Glove Last edited by vino; 10-02-2007 at 10:56 PM.. Reason: Added code tags |
![]() |
| Bookmarks |
| Tags |
| shell script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|