Date comparing in Unix shell script

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Date comparing in Unix shell script

 
0
  #1
Aug 30th, 2008
Hi all,

I am very new to Unix. Please help me to write a script.
Here is the discription of what the script should do:

The script won't need to be horribly complex; it's to check to see if the hawkagents(a process) on a server have been restarted since the last update to the Hawk rule files or the user variables file, and to generate an error message if they have not been.

-Please help me in finding last update time of a file.
-And last restarted time of a process.
-And how to capmare the date-time of above to times.

Thanks in advance.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Date comparing in Unix shell script

 
0
  #2
Aug 30th, 2008
Any particular "brand" of "unix"?
An awful lot of things claim to be "unix", even many things which only look like "unix".
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: Date comparing in Unix shell script

 
0
  #3
Aug 30th, 2008
Its Hp-Unix.

I think that is what you are asking.
And one thing the 'stat' command is not working on this unix box. Please help me.

Thanks for the response.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: Date comparing in Unix shell script

 
0
  #4
Sep 2nd, 2008
>date %s

is also not working in HP-UNIX.


Any response is highly appriciated.

Thanks.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Date comparing in Unix shell script

 
0
  #5
Sep 2nd, 2008
What about
date '+%s'
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: Date comparing in Unix shell script

 
0
  #6
Sep 3rd, 2008
same thing- it was written mistakly.

date "+%s"

is not working.

Any response is highly appriciated.

Thanks.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: Date comparing in Unix shell script

 
0
  #7
Sep 3rd, 2008
what I suggest:

I convert the date/time in secs using following command:

perl -e 'use Time::Local; my $time = timelocal(SS,MM,HH,DD,MM,YYYY); printf $time'

and then compare it.


Parsing last update time for any file is done by me using 'awk' and 'cut' command.

But I need to know a way find the start time of a process so that I can parse the date as I had done with the file.

In Sort I want a command to know that gives me startup time of a process so that I can parse it and can use it with perl command show above.

Thanks.
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC