The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Comparing two dates guptan Shell Programming and Scripting 5 11-25-2005 11:46 AM
Comparing last modified dates dmilks Shell Programming and Scripting 1 08-16-2005 10:01 PM
comparing dates svh High Level Programming 2 07-19-2005 11:04 AM
comparing 2 dates k_oops9 Shell Programming and Scripting 7 11-15-2004 02:07 AM
comparing 2 dates in Bourne shell scmay Shell Programming and Scripting 1 04-28-2004 08:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-24-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
comparing dates

Hi guys

I have a a variable called check_ts which holds a date value. this date value keeps refreshing every 15 minutes.

I am going to start a cron job 5 minutes after the refresh. I have to check if the current date > 20 min of check_ts. how do i do that.

thanks
ragha
  #2 (permalink)  
Old 10-24-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
the value of check_ts is like this


Code:
10/24/2006 3:15:47 PM

  #3 (permalink)  
Old 10-24-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
cal_days


Code:
#!/bin/perl
use Time::Local;
my $month=shift;
my $day=shift;
my $year=shift;
my $hour=shift;
my $min=shift;
my $sec=shift;
my $var=shift;
if ( "\u$var" =~ /PM/ )
{       $hour=$hour+12; }
my $time = timelocal(sec,min,hour,$day,$month-1,$year-1900);
my $time1 = timelocal(localtime());
my $days = ( $time1-$time ) / 60;
printf("%f", $days);


Code:
cal_days `echo $check_ts | sed -e "s/\// /g" -e "s/:/ /g"`

  #4 (permalink)  
Old 10-24-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
anbu

thanks a lot for the reply. is cal_days a seperate file. how do i invoke it and where do i implement my logic for checking if the current time is greater than 20 min or not. my shell script knowledge is very poor.

thanks
  #5 (permalink)  
Old 10-24-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398

Code:
tm=$(cal_days `echo $check_ts | sed -e "s/\// /g" -e "s/:/ /g"`)

if [ $tm -ge 20 ]
then
   echo "greater than or equal"
else
   echo "lesser"
fi

  #6 (permalink)  
Old 10-24-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
thanks a lot anbu.

is cal_days a file with .pl extension. where should i save that file. how will i invoke it as a function in my current file. pls elaborate on this. i appreciate your help. thanks again.
Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0