help for a script to increment time in hh:mm:ss format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help for a script to increment time in hh:mm:ss format
# 1  
Old 07-22-2010
help for a script to increment time in hh:mm:ss format

hi all,

I need help for incrementing time in hh:mm:ss format like for example :
when i have a values like 02:07:16 I want to increment this value with 5 secs till it reaches a condition.
Can someone help me with this.
Thanks in advance.
# 2  
Old 07-22-2010
Code:
..........................
.............................
mydate=`date +%k:%M:%S`
mysecond=`echo ${mydate##*:} + 5|bc`
myhour_minute=`echo ${mydate%*:*}`
if [[ `date +%k:%M:%S` ==  "02:07:16" ]] ; then 
    date +%T -s "${myhour_minute}:$mysecond" 
fi
..........................
.............................

# 3  
Old 07-22-2010
Why do not you use "sleep" function.
Code:
 
 
dt=date '+%H:%M:%S'
 
while [ $dt = {your condition} ]
do
    sleep 5
    dt=date '+%H:%M:%S'
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calculate Time diff in milli milliseconds(Time format : HH:MM:SS,NNN)

Hi All, I have one file which contains time for request and response. I want to calculate time difference in milliseconds for each line. This file can contain 10K lines. Sample file with 4 lines. for first line. Request Time: 15:23:45,255 Response Time: 15:23:45,258 Time diff... (6 Replies)
Discussion started by: Raza Ali
6 Replies

2. Shell Programming and Scripting

Change the date and time format in UNIX script.

Hi, I am extracting a date string from the source file like this : 06/05/2014 16:04:00 I want to change it to 05-JUN-14 04.05.00.000000000 PM I basically store the date in a variable. I got solutions to change date in dd-mmm-yyyy format using tr but I guess it works only with the "date"... (8 Replies)
Discussion started by: Varshha
8 Replies

3. Shell Programming and Scripting

Increment time

I have to increment time ... by sec but i am getting the output like this. for m in {2..3} > do > for (( i = 1; i <= 13; i++ )) > do > echo "$m:$i" > done > done 2:1 2:2 2:3 2:4 2:5 2:6 2:7 2:8 (2 Replies)
Discussion started by: kalyankalyan
2 Replies

4. Shell Programming and Scripting

Increment time stamps.

Hi Gents. Please can you help me to solve a problem. I have a long list of files, which I need to change the time stamp. -r--r--r-- 1 geo2 geovect 47096216 Feb 8 10:40 00000009.segd -r--r--r-- 1 geo2 geovect 47096216 Feb 8 10:40 00000010.segd -r--r--r-- 1 geo2 geovect 47096216 Feb ... (11 Replies)
Discussion started by: jiam912
11 Replies

5. Shell Programming and Scripting

How to increment date using "for loop" in format MMDDYY inside the shell script?

Need to increment the date from "currentdate + 90days" inside the for loop (i=1 to i=50) (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

6. Shell Programming and Scripting

Increment Date in a Specific Format

Hi, This may sound a Basic, but please help I Hava a date in the Given Format yyyy_mm_dd Start_date=2008_07_09 (This is a Fixed Date) I need to Increment this Date in a For loop until it equals Current Date For(Start_date<Current_date) xxxxxxxxxxxxxxxxxxxxxxxxxxxx... (0 Replies)
Discussion started by: dsshishya
0 Replies

7. Shell Programming and Scripting

How to increment a user defined date value in the DATE format itself using shell script?

I need to increment a date value through shell script. Input value consist of start date and end date in DATE format of unix. For eg. I need increment a date value of 1/1/09 to 31/12/09 i.e for a whole yr. The output must look like 1/1/09 2/2/09 . . . 31/1/09 . . 1/2/09 . 28/2/09... (1 Reply)
Discussion started by: sunil087
1 Replies

8. Shell Programming and Scripting

Different time format in script, started in shell or in cron

I try to write a python script, which analyze user logon time with "who" command. When i start script in bash, i get this result: USER=mnadmin tty7 2009-04-18 11:37 (:0) But when i start script in cron, i get result like this: USER=mnadmin tty7 Apr 18 11:37 (:0) I see -... (2 Replies)
Discussion started by: jrush
2 Replies

9. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

10. Shell Programming and Scripting

Date increment in the format "YYYYMMDD"

Hi all, I want to increment the date which is in the format "YYYYMMDD". ex: If the date is 20010601 Increment should be: 20010602, 20010603 etc., Any help will be much appreciated. Many Thanks and Regards, Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies
Login or Register to Ask a Question