How to add and extra hour to the start time


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
How to add and extra hour to the start time

Hi

Actually what am trying to ask is , i have an shell script ,now i want to run this shell script for one hour continuously and after one hour it has to stop automatically.
can any one suggest me how to automate the shell script ?
we tried wth the getting the start time and add ing an hour to that , but we faield in that ?

please any one help me in resolving this issue

thanks in advance
lalitha
# 2  
This is weird, why should you stop a script after one hour?
Clarify what you're trying to achieve with your script, show what have you tried so far and where you are stuck.

Regards
# 3  
Actually i am doing some regression testing ...................

where we need to test one driver continuously for one hour ........... and need to check whether the driver test is performing fine or not , and here is the script
otalcount=0
failcount=0
passcount=0
testcase=0
failing_test=0
PresentTime=$(date +%k%M)
let TargetTime=$PresentTime+100
echo "TargetTime is $TargetTime"
touch /home/mohanav/DeviceDrivers/Logs/CLK_one_hour.txt
cd /opt/qcom/bin/tests
echo "=================================================================================================== =========================="
let totalcount=totalcount+1;
iteration=0
while [ $iteration -lt 780 ]
do
let iteration_count=iteration+1
./clk_test.sh -v >> /home/mohanav/DeviceDrivers/Logs/CLK_one_hour.txt
if [ $? -ne 0 ]
then
echo $?
echo "script: TEST FAILED"
testcase="clk_test"
echo "testcase is = $testcase"
echo "the test cases failing in $iteration_count iteration is $testcase driver" >> /home/mohanav/DeviceDrivers/Repeatability/repeatability_clk_test.txt
let failcount=failcount+1;
fi
let iteration=iteration+1
done
echo "================

so we need to run this for one hour continuously ...........?
# 4  
Hammer & Screwdriver Here is an approach

The following is written to run for ten seconds; adjust the 10 to the appropriate number of seconds. (I did for ten for easier testing and to see that it works.)

Code:
> cat run_time
#! /usr/bin/bash

#variables
initial_time="test_file_start"
current_time="test_file_current"
time_diff_goal=10  # the number of seconds before exit

touch $initial_time
time1=`stat -c %Y $initial_time`

while [ 1 -eq 1 ]
   do

# do some stuff here

      touch $current_time
      time2=`stat -c %Y $current_time`

      time_diff=`echo $time2 - $time1 | bc`
      if [ $time_diff -ge $time_diff_goal ]
         then
         echo $time_diff
         exit 99
      fi
done

# 5  
Hi

thanks for your response, i am trying to execute your script but while executing the belwo command

time1=`stat -c %Y $initial_time` in the linux console

i am getting an error as " stat not found"

????
# 7  
Hammer & Screwdriver Perhaps someone with more specific linux can help

I approached from a general unix perspective.
A quick google search seemed to show that stat was available in linux.
Linux Command Directory: stat
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How to convert 24 hour time to 12 hour timing?
nex_asp
Hi friends, I want to convert 24 hour timing to 12 hour please help me... my data file looks like this.. 13-Nov-2011 13:27:36 15.32044 72.68502 13-Nov-2011 12:08:31 15.31291 72.69807 16-Nov-2011 01:16:54 15.30844 72.74028 15-Nov-2011 20:09:25 15.35096 ...... Shell Programming and Scripting
13
Shell Programming and Scripting
add one hour to each time field
panyam
Hello All, Is there any *easy* and efficient way to add "one hour" to few fields in a file? . I have done this using a python script and it has hit with performance issues. I have around 200mi of records, which I need to modify and send across in one hour. sample input: '2012-10-17...... Shell Programming and Scripting
2
Shell Programming and Scripting
How to add an hour or a minute to a time?
irudayaraj
Hi, The timestamp is June 06 2011 11:05AM i need 2 results. first, an hour added to it, June 06 2011 12:05AM second, a minute added to it, June 06 2011 11:06AM How can i do this? Also when it reaches 12:59, it needs to start from 1 again without giving the output as 13:00. it...... UNIX for Dummies Questions & Answers
17
UNIX for Dummies Questions & Answers
Time getting reduced by 1 hour
januuj23
I am setting TZ=EST5EDT,M3.2.0/02:00:00,M11.1.0/02:00:00 Then Setting the date to Mar 14 01:40 EST date 0314014010 Sun Mar 14 01:40:36 EDT 2010 Note that it show it EST. According to my TZ variable 01:40 Should be in EST only. On executing date command once again it shows date Sun Mar...... AIX
4
AIX
Start program in background (or start crontab ahead of time)
noratx
Hey! I'm working on a script that will add a user, create some configfiles, and add a crontab for the user. The crontab looks like the following: @reboot /home/user/program config.conf & I would like for this process to start at the end of my script under the corresponding username by...... Shell Programming and Scripting
0
Shell Programming and Scripting