Sponsored Content
Top Forums Shell Programming and Scripting search for a file, if not found sleep and repeat it for 3 hrs Post 302245141 by treesloth on Thursday 9th of October 2008 12:15:52 PM
Old 10-09-2008
This won't be a complete answer, as ksh really isn't my thing; however, I would base a quick and dirty script of this kind you describe on the fact that there are 18 10-minute periods in 3 hours. So, something like this might be a reasonable framework:

Code:
integer n=0
while ((n <= 18));
do
     if [[ -e filename ]]
          then
               integer n=19
          else
               if [[ n = 18 ]]
                    Send your mail with whatever command you need....
               else
                    sleep 600
               fi
     fi
n++
done

Anyway, that's the idea... it'll require lots of work, and I would be stunned if it ran without significant alteration. Some of it probably isn't even valid ksh. Hopefully it gives you a starting point, though.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check for new file over 24 hrs

Hi all, I am trying to figure out a method to flag an error if a file has not arrived in a certain directory within 24 hrs of the last one arriving. I am currently writing the time to a file when a file is recieved. I then want to check for a new file reguarly but flag an error if it has been... (3 Replies)
Discussion started by: pxy2d1
3 Replies

2. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

3. Shell Programming and Scripting

Wrapping 'sleep' with my 'resleep' function (Resettable sleep)

This is a very crude attempt in Bash at something that I needed but didn't seem to find in the 'sleep' command. However, I would like to be able to do it without the need for the temp file. Please go easy on me if this is already possible in some other way: How many times have you used the... (5 Replies)
Discussion started by: deckard
5 Replies

4. Shell Programming and Scripting

List last 10 Hrs file and find error files

Hi, I need a script that can search a word "Error" in last 10 Hrs generated logs in /log/App1 and /log/App2 folder.. Note these directories have massive log files ...actually our application generate 100 Log files of size 2MB in just a min so script must be fast enough to cater this I... (9 Replies)
Discussion started by: Mujtaba khan
9 Replies

5. Shell Programming and Scripting

Search for file, give error if more than one file is found

Want to write a function that prints an error when passed a list of file names. If the file list is empty, print error "no file found", if there are more than one file, print "error more than one file found" (22 Replies)
Discussion started by: kristinu
22 Replies

6. Shell Programming and Scripting

bash script search file and insert character when match found

Hi I need a bash script that can search through a text file and when it finds 'FSS1206' I need to put a Letter F 100 spaces after the second instance of FSS1206 The format is the same throughout the file I need to repeat this on every time it finds the second 'FSS1206' in the file I have... (0 Replies)
Discussion started by: firefox2k2
0 Replies

7. Shell Programming and Scripting

Search row by row from one file to another file if match is found print few colums of file 2

this is the requirement list.txt table1 table2 table3 testfile.txt name#place#data#select * from table1 name2#place2#data2#select * from table 10 innerjoin table3 name2#place2#data2#select * from table 10 output name place table1 name2 place table3 i tried using awk (7 Replies)
Discussion started by: vamsekumar
7 Replies

8. UNIX for Dummies Questions & Answers

Sum third column in a file when 1 and 2 repeat

Hello, Below is a portion of a file I am working on: 2:15 3001 120 2:15 3001 26.25 2:15 3002 12.5 2:15 3002 15 9:45 3001 45 9:45 3001 45 9:45 3002 105 9:45 3005 180 9:45 3005 123.75 9:45 3005 15 I am trying to get the sum of column 3 for all repeated values of columns 1 and 2 (The... (6 Replies)
Discussion started by: c@rlos
6 Replies

9. Shell Programming and Scripting

Check if file got created in less than 10 hrs

Dear Gurus, I want to check if file got created in less than 10 hrs in .ksh. Here is my requirement In $var5 : I'm storing file name In $var4 I have stored : select to_char(sysdate,'YYYYMMDDHH:MM:SS') from dual; If that file date time is less than 10 hrs, then I need to check if less... (1 Reply)
Discussion started by: thummi9090
1 Replies

10. Shell Programming and Scripting

Bash to search file for string and lauch function if found

In the bash below I am searching the filevirus-scan.log for the Infected files: 0 line (in bold) and each line for OK. If both of these are true then the function execute is automatically called and processing starts. If both these conditions are not meet then the line in the file is sent to the... (2 Replies)
Discussion started by: cmccabe
2 Replies
Time::Clock(3pm)					User Contributed Perl Documentation					  Time::Clock(3pm)

NAME
Time::Clock - Twenty-four hour clock object with nanosecond precision. SYNOPSIS
$t = Time::Clock->new(hour => 12, minute => 34, second => 56); print $t->as_string; # 12:34:56 $t->parse('8pm'); print "$t"; # 20:00:00 print $t->format('%I:%M %p'); # 08:00 PM $t->add(minutes => 15, nanoseconds => 123000000); print $t->as_string; # 20:15:00.123 $t->subtract(hours => 30); print $t->as_string; # 14:15:00.123 ... DESCRIPTION
A Time::Clock object is a twenty-four hour clock with nanosecond precision and wrap-around. It is a clock only; it has absolutely no concept of dates. Vagaries of date/time such as leap seconds and daylight savings time are unsupported. When a Time::Clock object hits 23:59:59.999999999 and at least one more nanosecond is added, it will wrap around to 00:00:00.000000000. This works in reverse when time is subtracted. Time::Clock objects automatically stringify to a user-definable format. CLASS METHODS
default_format FORMAT Set the default format used by the as_string method for all objects of this class. Defaults to "%H:%M:%S%n". See the documentation for the format method for a complete list of format specifiers. Note that this method may also be called as an object method, in which case it sets the default format for the individual object only. CONSTRUCTOR
new PARAMS Constructs a new Time::Clock object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name. Example: $t = Time::Clock->new(hour => 12, minute => 34, second => 56); If a single argument is passed to new, it is equivalent to calling the parse method. That is, this: $t = Time::Clock->new('12:34:56'); is equivalent to this: $t = Time::Clock->new; $t->parse('12:34:56'); Returns the newly constructed Time::Clock object. OBJECT METHODS
add PARAMS Add the time specified by PARAMS to the clock. Valid PARAMS are: "hours INT" An integer number of hours. "minutes INT" An integer number of minutes. "seconds INT" An integer number of seconds. "nanoseconds INT" An integer number of nanoseconds. If the amount of time added is large enough, the clock will wrap around from 23:59:59.999999999 to 00:00:00.000000000 as needed. ampm AM/PM Get or set the AM/PM attribute of the clock. Valid values of AM/PM must contain the letters "AM" or "PM" (case-insensitive), optionally followed by periods. A clock whose hour is greater than 12 cannot be set to AM. Any attempt to do so will cause a fatal error. Setting a clock whose hour is less than 12 to PM will cause its hour to be increased by 12. Example: $t = Time::Clock->new('8:00'); print $t->as_string; # 08:00:00 $t->ampm('PM'); print $t->as_string; # 20:00:00 Return the string "AM" if the hour is less than 12, "PM" otherwise. as_integer_seconds Returns the integer number of seconds since 00:00:00. as_string Returns a string representation of the clock, formatted according to the clock object's default_format. default_format FORMAT Set the default format used by the as_string method for this object. Defaults to "%H:%M:%S%n". See the documentation for the format method for a complete list of format specifiers. Note that this method may also be called as a class method, in which case it sets the default format all objects of this class. format FORMAT Returns the clock value formatted according to the FORMAT string containing "%"-prefixed format specifiers. Valid format specifiers are: %H The hour as a two-digit, zero-padded integer using a 24-hour clock (range 00 to 23). %I The hour as a two-digit, zero-padded integer using a 12-hour clock (range 01 to 12). %i The hour as an integer using a 12-hour clock (range 1 to 12). %k The hour as an integer using a 24-hour clock (range 0 to 23). %M The minute as a two-digit, zero-padded integer (range 00 to 59). %n If the clock has a non-zero nanosecond value, then this format produces a decimal point followed by the fractional seconds up to and including the last non-zero digit. If no nanosecond value is defined, or if it is zero, then this format produces an empty string. Examples: $t = Time::Clock->new('12:34:56'); print $t->format('%H:%M:%S%n'); # 12:34:56 $t->nanosecond(0); print $t->format('%H:%M:%S%n'); # 12:34:56 $t->nanosecond(123000000); print $t->format('%H:%M:%S%n'); # 12:34:56.123 "%[1-9]n" If the clock has a defined nanosecond value, then this format produces a decimal point followed by the specified number of digits of fractional seconds (1-9). Examples: $t = Time::Clock->new('12:34:56'); print $t->format('%H:%M:%S%4n'); # 12:34:56 $t->nanosecond(0); print $t->format('%H:%M:%S%4n'); # 12:34:56.0000 $t->nanosecond(123000000); print $t->format('%H:%M:%S%4n'); # 12:34:56.1230 %N Nanoseconds as a nine-digit, zero-padded integer (range 000000000 to 999999999) "%[1-9]N" Fractional seconds as a one- to nine-digit, zero-padded integer. Examples: $t = Time::Clock->new('12:34:56'); print $t->format('%H:%M:%S.%4N'); # 12:34:56.0000 $t->nanosecond(123000000); print $t->format('%H:%M:%S.%6N'); # 12:34:56.123000 $t->nanosecond(123000000); print $t->format('%H:%M:%S.%2N'); # 12:34:56.12 %p Either "AM" or "PM" according to the value return by the ampm method. %P Like %p but lowercase: "am" or "pm" %S The second as a two-digit, zero-padded integer (range 00 to 61). %s The integer number of seconds since 00:00:00. %T The time in 24-hour notation (%H:%M:%S). "%%" A literal "%" character. hour INT Get or set the hour of the clock. INT must be an integer from 0 to 23. minute INT Get or set the minute of the clock. INT must be an integer from 0 to 59. nanosecond INT Get or set the nanosecond of the clock. INT must be an integer from 0 to 999999999. parse STRING Set the clock time by parsing STRING. Valid string values contain an hour with optional minutes, seconds, fractional seconds, and AM/PM string. There should be a colon (":") between hours, minutes, and seconds, and a decimal point (".") between the seconds and fractional seconds. Fractional seconds may contain up to 9 digits. The AM/PM string is case-insensitive and may have periods after each letter. The string "now" will initialize the clock object with the current (local) time. If the Time::HiRes module is installed, this time will have fractional seconds. A time value with an hour of 24 and zero minutes, seconds, and nanoseconds is also accepted by this method. Here are some examples of valid time strings: 12:34:56.123456789 12:34:56.123 PM 24:00 8:30pm 6 A.m. now second INT Get or set the second of the clock. INT must be an integer from 0 to 59. subtract PARAMS Subtract the time specified by PARAMS from the clock. Valid PARAMS are: "hours INT" An integer number of hours. "minutes INT" An integer number of minutes. "seconds INT" An integer number of seconds. "nanoseconds INT" An integer number of nanoseconds. If the amount of time subtracted is large enough, the clock will wrap around from 00:00:00.000000000 to 23:59:59.999999999 as needed. AUTHOR
John C. Siracusa (siracusa@gmail.com) LICENSE
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-06-04 Time::Clock(3pm)
All times are GMT -4. The time now is 05:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy