System time comparison to fixed defined time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting System time comparison to fixed defined time
# 1  
Old 03-22-2009
System time comparison to fixed defined time

I have a requirement of checking the current system time and performing certain actions in a shell script. example:

if the current system time is greater than 1400 hrs, then perform step 1,2,3
if the current system time is greater than 1000 hrs, then perform step 1,2
if the current system time is greater than 0530 hrs, then perform step 1

is there any way for me to do this comparison in UNIX using variables/awk/perl? Kndly guide.
# 2  
Old 03-22-2009
With awk you can do something like this:

Code:
awk -v t=$(date "+%H%M") '
BEGIN {
  if(t > 1400){
    ...
  }
  else if(t > 1000){
    ...
  }
  else if(t > 0530){
    ...
  }
}'

Regards
# 3  
Old 03-22-2009
works like a charm Smilie

Thanks Franklin52
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process monitoring for a fixed time

Hi Gurus, I have a scenario where i need to monitor for a process which starts at a particular time. I need to check if the process has started at the specified time and keep checking this for 5 minutes only and then want to alert me. ps -ef | grep -i process.sh | grep -v grep >... (5 Replies)
Discussion started by: jayadanabalan
5 Replies

2. Linux

Time: Hwclock and System Time

Hey everyone. Upon studying linux trying to learn it inside and out, I'm reading about the issue of time. Hardware clock time vs the more commonly referenced System Time. What causes the two to grow apart, and what causes the time itself to stray away from UTC? at present my clock is a second and... (1 Reply)
Discussion started by: Lost in Cyberia
1 Replies

3. Shell Programming and Scripting

Additional time to system time

Hi All, Is there any command to add additional time to date command. I need to add 5 hours to the present system time. I am getting the time by using date command. WORKFLOW_START_TIME=`date +%m/%d/%Y\ %H:%M:%S` Thanks (8 Replies)
Discussion started by: nag_sathi
8 Replies

4. Shell Programming and Scripting

what would a script include to find CPU's %system time high and user time high?

Hi , I am trying to :wall: my head while scripting ..I am really new to this stuff , never did it before :( . how to find cpu's system high time and user time high in a script?? thanks , help would be appreciated ! :) (9 Replies)
Discussion started by: sushwey
9 Replies

5. Solaris

System time and Cron time stamp not matching

On Solaris 10 server the system date won't match with the timestamp on files created by a cron jobs, Please help here is what i get when i check for system date infodba-ie10ux014:/tcpdv1_ie10/tcadmin/bin\n\r-> date Tue Apr 24 15:27:43 GMT 2012at same time i executed a cron job, and checked... (4 Replies)
Discussion started by: karghum
4 Replies

6. Solaris

getting time independent of system time in solaries

i am using function gethrtime() in sun solaries to get the time independent of the system time.Problem with this function is if we restart the system time will change to '0'.is there any other way to resolve this problem. thanks & regards suresh (3 Replies)
Discussion started by: suresh_rtp
3 Replies

7. Shell Programming and Scripting

Date comparison in file to system time

I have a CSV (comma separated vaule) file whose entries resemble Area,\\ntsvsp02\vmcs\download\files\Areas.dat,1,20090303,0,Import Complete,2009-03-02 04:23:00 Product,\\ntsvsp02\vmcs\download\files\items.dat,1,20090303,0,Import Complete,2009-03-02 04:23:00... (3 Replies)
Discussion started by: zainravi
3 Replies

8. Shell Programming and Scripting

Time comparison

hi friends, I am new to shell scripting and i am using KSH shell .I would like to automate our daily routine manual tasks .first i ll explain the situation .I will list out the contents of directory named "log" using "ls " and verify whether all the listed files time differences is... (3 Replies)
Discussion started by: rdhaprakasam
3 Replies

9. Shell Programming and Scripting

Newbee Needs Help - Time comparison

I am very new to Unix so please bear with me! I am trying to write a script that will compare file creation time with the current time so I can be notified if a file is more than an hour old. Can anybody point me in the right direction on this??? Thank you in advance for any help!!! It is GREATLY... (4 Replies)
Discussion started by: danedder
4 Replies
Login or Register to Ask a Question