How to add and extra hour to the start time

linux, start, time

Thread Tools Search this Thread
# 1  
Old 10-17-2008
How to add and extra hour to the start time


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
# 2  
Old 10-17-2008
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.

# 3  
Old 10-17-2008
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
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;
while [ $iteration -lt 780 ]
let iteration_count=iteration+1
./ -v >> /home/mohanav/DeviceDrivers/Logs/CLK_one_hour.txt
if [ $? -ne 0 ]
echo $?
echo "script: TEST FAILED"
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;
let iteration=iteration+1
echo "================

so we need to run this for one hour continuously ...........?
# 4  
Old 10-17-2008
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.)

> cat run_time
#! /usr/bin/bash

time_diff_goal=10  # the number of seconds before exit

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

while [ 1 -eq 1 ]

# 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 ]
         echo $time_diff
         exit 99

# 5  
Old 10-17-2008

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"

# 6  
Old 10-17-2008
and by the way I need the answer using shell script
# 7  
Old 10-17-2008
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

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
NFS Share Time an Hour Ahead Paul Standley Windows & DOS: Issues & Discussions 1 04-04-2015 12:03 AM
How to convert 24 hour time to 12 hour timing? nex_asp Shell Programming and Scripting 13 01-30-2013 05:24 AM
add one hour to each time field panyam Shell Programming and Scripting 2 10-25-2012 07:24 AM
crontab 1 hour off from current time homeyjoe AIX 2 03-09-2012 10:58 AM
Incrementing a time by one hour issues Junes Shell Programming and Scripting 2 09-29-2011 03:08 AM
How to add an hour or a minute to a time? irudayaraj UNIX for Dummies Questions & Answers 17 07-29-2011 12:25 PM
Doing math on 24 hour time base jondecker76 Shell Programming and Scripting 3 06-23-2011 12:39 PM
How to calculate time difference between start and end time of a process! smarty86 Shell Programming and Scripting 16 09-03-2010 04:15 PM
How do i set time in 24 hour format? pinga123 UNIX for Dummies Questions & Answers 8 04-13-2010 05:05 PM
Time getting reduced by 1 hour januuj23 AIX 4 10-15-2009 07:30 PM
Start program in background (or start crontab ahead of time) noratx Shell Programming and Scripting 0 07-21-2009 07:06 AM
How to set NTP server to +1 hour time? chmelvv UNIX for Advanced & Expert Users 2 03-26-2009 07:03 PM
getting hour minus the current time shehzad_m Shell Programming and Scripting 7 08-23-2008 07:47 AM
Start time/end time and status of crontab job thambi Shell Programming and Scripting 3 05-16-2007 11:24 AM