| | |
Date comparing in Unix shell script
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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.
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.
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.
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.
![]() |
Similar Threads
- Script to compare dates? (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: Shell Scripting Problem
- Next Thread: [sh] file operations
| Thread Tools | Search this Thread |






