The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do i put a time stamp in a file name jhamm Shell Programming and Scripting 5 01-29-2007 07:00 AM
Date/Time Stamp JimmyFlip UNIX for Dummies Questions & Answers 0 11-14-2006 08:49 PM
greping with time stamp arunkumar_mca Shell Programming and Scripting 1 07-28-2006 01:20 AM
capturing the time stamp pavan_test UNIX for Dummies Questions & Answers 4 07-18-2006 10:35 AM
Date Time Stamp jarich Shell Programming and Scripting 2 07-28-2005 06:28 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-22-2007
Registered User
 

Join Date: Jul 2007
Posts: 6
Question checking time stamp

Hi,
I am having a script in which I am again calling a script, but before calling that script I need to perform a time check (say 1 - 2 am i.e. I would be able to call that script if time is between 1:00 am and 2:00 am) but this time stamp needs to be configurable.
can anybody suggest me how I can achive this..


Thanks in advance
Manvar
Reply With Quote
Forum Sponsor
  #2  
Old 08-22-2007
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
Thumbs up

Quote:
Originally Posted by Manvar Khan View Post
Hi,
I am having a script in which I am again calling a script, but before calling that script I need to perform a time check (say 1 - 2 am i.e. I would be able to call that script if time is between 1:00 am and 2:00 am) but this time stamp needs to be configurable.
can anybody suggest me how I can achive this..


Thanks in advance
Manvar

You can do something like this--

#!/bin/ksh
echo "To run a script in between a given time"
str1=`date | cut -d" " -f4`
str2=`echo $str1 | cut -d":" -f1`
if [[ $str2 -eq 13 ]] or if [[ $(date +%h) -eq 13 ]]
then
ksh test2
else
echo "Wrong"
fi


Thanks
Namish

Last edited by namishtiwari; 08-22-2007 at 01:19 AM.
Reply With Quote
  #3  
Old 08-22-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Without so many 'cut's
Code:
#! /bin/ksh

if [[ $(date +%H) -eq 01 ]] ; then
  echo "Judgement day has arrived"   # run the script
else
  echo "Judgement day has not arrived"
fi
Reply With Quote
  #4  
Old 08-22-2007
Registered User
 

Join Date: Jul 2007
Posts: 6
thanks Namish for your reply,
but this is not the solution I want, as per your solution

if [[ $str2 -eq 13 ]]

now in future if I want to change 13 to 15 then I have make changes in the code.
and I dont want to cahnge in the code.
I want my script capable of taking this time from some where outside this script.
I hope you got my problem.

Regards
Manvar
Reply With Quote
  #5  
Old 08-22-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Code:
#! /bin/ksh
#
#

case $# in
    2) start=$1; end=$2 ;;
    *) echo "Need a start and end time"; exit 1;;
esac

now=$(date +%H)
if [[ $now -ge $start && $now -lt $end ]] ;
then
    echo "Judgement Day has arrived."
else
    echo "Judgement Dat yet to arrive."
fi;
Reply With Quote
  #6  
Old 08-22-2007
Registered User
 

Join Date: Jul 2007
Posts: 6
thanks vino,
I am sorry I forgot to tell that we cannot use command line aurguments here (It is the requirement).

Regards
Manvar
Reply With Quote
  #7  
Old 08-22-2007
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
Thumbs up

Manvar,
You can read the time like this

echo "Enter the start time stamp"
read stime

echo "Enter the end time"
read etime

and do your manipulations on these variables itself.
is that going to help you.

Thanks
Namish
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0