![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| epoch time in shell script | robsonde | SUN Solaris | 14 | 05-12-2009 12:08 PM |
| Time out in shell script for a stament/line | gvsreddy_539 | Shell Programming and Scripting | 5 | 10-02-2007 10:12 AM |
| Newbee Needs Help - Time comparison | danedder | Shell Programming and Scripting | 4 | 05-25-2005 12:26 PM |
| C shell script for time matching | Ringo | Shell Programming and Scripting | 1 | 08-07-2003 01:26 PM |
| File Time Comparison Question | pc9456 | UNIX for Advanced & Expert Users | 2 | 07-23-2003 03:05 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help with time comparison shell script for HP-UX
I am using Korne Shell in HP-Ux. Can someone give me and idea on how I can write a shellscript on how to do this please:-
On our HP-UX server, a batch file is run every evening at about 6:30pm. The first step of this batch file will touch an empty "flag" file to indicate that the batch has already started running. This flag is removed at the end of the evening batch file. So bascially, as long as this flag exists, the batch file is not allowed to be run by another operator. The problem is I need to built in some testing that if the batch file has already been run once within the 24 hours cycle, it mustn't be run again. I thought about setting a timestamp into the "flag" file I create at the beginning of the batch run and call it "BatchRunning". Then rename this flag file and call it "batchRan" so it will be served as sort of time marker for comparison later. So if the batch file is re-run then a comparison can be made between the two files "BatchRunning" and "batchRan". If "BatchRunning" is less than "batchRan" by 24 hours then abort the batch file immedately and display a message to the operator. So that's the theory, how do I script this in Korne Shell please?? Please help me ... as I have tried to search the forum for clues .... and I am really stuck now.. In my search, on time comparison, it picked up the "datecalc" script but I am not sure if it can be applied to my problem ( it looks far too complicated).Many thanks in advance, |
|
||||
|
No, can't use crontab at all because the batch file is not always run at 6:30pm. Sometimes, the end of days can finish late. On some of our servers, the evening batch file can only be run if another system has finished. This is why the batches can only be kicked off by our operators in a manual mode if you like.
Thanks for your suggestion anyway .... |
|
||||
|
- You can use 'touch' to create the lock files.
- day=`date +%d` gives the day value of now - minutes=`date +%m` gives the minute value of now - ls -l /path/to/dir/file | awk '{print $7}' gives the date entry of the file - file1 -nt file2 True, if file1 exists and is newer than file2. - file1 -ot file2 True, if file1 exists and is older than file2. With this information you should be able to write the script. |
|
||||
|
Just to say thank you all for looking at my initial query. Using some of the hints given here, I have come up with a script which does the job. Being a newbie to Unix Support, I have found this forum very supportive.
![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|