![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
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. |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
||||
|
||||
|
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;
|
|
#6
|
|||
|
|||
|
thanks vino,
I am sorry I forgot to tell that we cannot use command line aurguments here (It is the requirement). Regards Manvar |
|
#7
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |