LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-20-2014, 01:45 AM   #1
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Rep: Reputation: Disabled
How to add 5 minutes to the time


i have jobs and their schedule run time as:

#JOB SCHEDULES
A 05:30
B 06:57
C 06:59
D 07:58

i want to add 5 mins to their schedule and display the new time ? How could we do that? could someone please help?
 
Old 03-20-2014, 02:59 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,476

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
You provide no usable information whatsoever.

Where are these jobs defined? What are you using to display the current time? Are these cron jobs? jobs within an application? or website?

We have no psychic powers, give us a clue.
 
Old 03-20-2014, 04:29 AM   #3
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Hi,
Actually, the requirement is here:

currTime=$( date +'%R' ) # HH:MM
currHour=$( date +'%H' ) # HH
currMin=$( date +'%M' ) # MM

scheduled_time:
05:30
06:40
06:45
07:15
08:10
08:30
08:35
09:15
09:30
09:35

13:15
13:25
13:30
14:20
14:40
14:45
17:45
18:00
18:05
18:40
19:00
18:30
19:05

22:15
23:00
23:15
23:55
05:30
06:00


everyday i have to check:

if [[ "$currTime" == "$(scheduled_time +5 minutes)" ]]
then
do something
fi

how to add 5 minutes to the above scheduled_times?

Last edited by santosh0782; 03-20-2014 at 04:32 AM.
 
Old 03-20-2014, 04:55 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
If using GNU date you can try the -d option of the command:
Code:
date -d "$currTime 5 minutes" +%R
 
2 members found this post helpful.
Old 03-20-2014, 07:00 AM   #5
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by colucix View Post
If using GNU date you can try the -d option of the command:
Code:
date -d "$currTime 5 minutes" +%R
Thanks a lot.. its working fine :-)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Clock 4 minutes behind actual time on CentOS 6.4 virtualn00b Linux - Distributions 6 09-12-2013 10:10 AM
Crontab question (Every few minutes after a certain time) Norwood Linux - Newbie 5 03-08-2010 02:41 PM
ntp time 12 minutes slow GregLee Linux - Software 8 09-14-2009 11:22 AM
dvdauthor: add chapter every x minutes? applewax Linux - Software 2 04-29-2006 02:54 PM
Is 15 minutes a good time for ripping a CD Boffy Linux - General 4 08-26-2004 06:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration