How to Increment or add minutes???;-)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Increment or add minutes???;-)
# 1  
Old 08-19-2008
How to Increment or add minutes???;-)

Hi all,

I want to add a minute to present time.
E.g:
if present time is 09:55, I want to make it 09:56.

Please help!!

I tried below script

#!/bin/ksh

timeut=`date -u '+%R'`
let timeut1=$timeut + 1
echo "timeut1 = $timeut1"


Regards
PrashantSmilie
# 2  
Old 08-19-2008
Try this:

Code:
perl -e '@d=localtime time() + 600; printf "%02d:%02d%s\n",$d[2]%12,$d[1],("AM","PM")[$d[2]/12]'

It adds 10 minutes to the current time.
# 3  
Old 08-19-2008
Quote:
Originally Posted by nua7
Try this:

Code:
perl -e '@d=localtime time() + 600; printf "%02d:%02d%s\n",$d[2]%12,$d[1],("AM","PM")[$d[2]/12]'

It adds 10 minutes to the current time.
............


(perl is not supported here)Smilie
.can u gimee the answer in pure korn shell scripting
# 4  
Old 08-19-2008
try TZ..
first check this echo "$TZ"
it shows something like this
IST - 5:30 i guess
then TZ=IST - 5:31(not sure try + or -)
then type date you may get one min forward time
then change back the TZ to normal..
# 5  
Old 08-19-2008
Quote:
Originally Posted by vidyadhar85
try TZ..
first check this echo "$TZ"
it shows something like this
IST - 5:30 i guess
then TZ=IST - 5:31(not sure try + or -)
then type date you may get one min forward time
then change back the TZ to normal..
Thanks for reply...
but
MY SERVER TIME ZONE IS MST.
SO echo "$TZ" shows me MST7 as output.
so this will not help!!

Here I am converting MST time into GMT by date -u '+%R' (eg:15:44).
further I dont know how to increment(eg. 15:44 to 15:45).
# 6  
Old 08-19-2008
are you using HP-UX??
then gothrough tztab man page once.. it may help..
# 7  
Old 08-19-2008
timehh=`date -u '+%H'`
timemm=`date -u '+%M'`
curr_time="$timehh:$timemm"
timemm=`expr $timemm + 1`
new_time="$timehh:$timemm"
echo "$curr_time === $new_time"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check file creation Time minutes and if file older then 5 minutes execute some stuff

Hello all, Info: System RedHat 7.5 I need to create a script that based on the creation time, if the file is older then 5 minutes then execute some stuff, if not exit. I thought to get the creation time and minutes like this. CreationTime=$(stat -c %y /tmp/test.log | awk -F" " '{ print... (3 Replies)
Discussion started by: charli1
3 Replies

2. Shell Programming and Scripting

Grep a log file for the last 5 minutes of contents every 5 minutes

Hi all, System Ubuntu 16.04.3 LTS i have the following log INFO 2019-02-07 15:13:31,099 module.py:700] default: "POST /join/8550614e-3e94-4fa5-9ab2-135eefa69c1b HTTP/1.0" 500 2042 INFO 2019-02-07 15:13:31,569 module.py:700] default: "POST /join/6cb9c452-dcb1-45f3-bcca-e33f5d450105... (15 Replies)
Discussion started by: charli1
15 Replies

3. UNIX for Beginners Questions & Answers

How to convert days hours minutes seconds to minutes?

Hi, please help with below time conversion to minutes. one column values: 2 minutes 16 seconds 420 msec 43 seconds 750 msec 0 days 3 hours 29 minutes 58 seconds 480 msec 11 seconds 150 msec I need output in minutes(total elapsed time in minutes) (2 Replies)
Discussion started by: ramu.badugula
2 Replies

4. Shell Programming and Scripting

Add or Subtract the hours,minutes or seconds in the the time variable

Hello All, I am working on script where I need to add hours,minutes or seconds in the time.Time is not the current but it could be future time.I thought I can store that time in variable and add hours.minutes or second but I am not able to add that in the time that is stores in a variable. Time... (9 Replies)
Discussion started by: anuragpgtgerman
9 Replies

5. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

6. Shell Programming and Scripting

[Solved] Working with date (add minutes using variables)

Dear all, today I'm scratching my head with a simple (I believe) issue. Working with date is quite simple, so if I Need to add some seconds to current time, I'll use: date --date='+30 seconds' +"%Y-%m-%d %H:%M:%S"But, how to pass the value to add from a variable? I tried the following without... (2 Replies)
Discussion started by: Lord Spectre
2 Replies

7. Shell Programming and Scripting

Add minutes in Datetime Variable in Unix

Hi, New to scripting. I have datetime as a String and I need to add some hours/minutes in to that. 21/10/2009 23:00:00 After adding 180 minutes; it will look like this 22/10/2009 02:00:00 Regards, Vikas Mahajan (9 Replies)
Discussion started by: vikas482
9 Replies

8. Shell Programming and Scripting

Increment value (starttime)

Hi All, I have created a script... #!/bin/sh datafile=ABC2008101601.OUT indfile=ABCIND20081016.1.OUT waittime=600 starttime=0 while do if then echo "Indicator file has arrived." break else sleep 10; ((starttime=$starttime+10)) echo $starttime (2 Replies)
Discussion started by: Amit.Sagpariya
2 Replies

9. Shell Programming and Scripting

Convert minutes to hours, minutes, seconds

How would you convert lets say a 1000 minutes to hours, minutes, seconds (1 Reply)
Discussion started by: Vozx
1 Replies

10. Shell Programming and Scripting

add increment field when first field changes

Hi I have a file that looks like the following: Name1 aaa bbbb Name1 ffd hhghg Name1 dffg ghhhh Name2 rtrt dfff Name2 rrtfr tgtt Name2 dsddf gfggf Name2 ffffg gfgf NAme3 fdff ghhgh Is it possible to format it so that a number... (2 Replies)
Discussion started by: azekry
2 Replies
Login or Register to Ask a Question