The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-02-2007
Glove Glove is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 1
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
If you can help me that would be great.


Thanks,

Glove

Last edited by vino; 10-02-2007 at 10:56 PM.. Reason: Added code tags
  #2 (permalink)  
Old 10-03-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
check if $((hours+minutes-second)) results in a numeric value in the shell that you are using
Closed Thread

Bookmarks

Tags
shell script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0