Sponsored Content
Full Discussion: File monitor and alert
Top Forums Shell Programming and Scripting File monitor and alert Post 302995551 by jim mcnamara on Friday 7th of April 2017 10:33:37 AM
Old 04-07-2017
-mmin is not available for all versions of find. Also -mtime +1 means that the file is last modified more than 86400 seconds ago. Not how us humans think of yesterday.

Consider:
Code:
#!/bin/sh
# ago.shl
# usage: ago.shl [number] 
#       for date [number] days ago, at midnight, last second of that day.
#       ./ago.shl 3 /path/to/myfile
#   parms $1 days in past 
#         $2 name of  file to change mtime on
ago()
{
   perl -e ' my $delta = $ARGV[0];
             $delta*=86400;
             $delta=time - $delta;   #  subtract delta from "now"
              ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                                                            localtime($delta);
             
             printf("%04d%02d%02d%02d%02d.%02d\n",
                     $year+1900, $mon+1, $mday, 23, 59, 59);
             ' $1
}

# ago 1  last second of yesterday i.e., 2017062359.59 in touch format

when=$(ago $1)
# echo "$when"
touch -t "$when" $2
exit 0

These 2 Users Gave Thanks to jim mcnamara For This Post:
 

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to monitor files in a directory and sending the alert

Hi All, We are having important config files in an directory which was accessable by all /auto/config/Testbed/>ls config1.intial config2.intial config3.inital often we find that some of the lines are missing in config files, we doubt if some one is removing. I would like to write... (0 Replies)
Discussion started by: shellscripter
0 Replies

2. AIX

Alert: Network Status Monitor daemon (rpcstat) is not running

Hi I am currently testing SCOM2012 on my AIX systems for monitoring. I tested it on 3 systems and immediately i got the following errors: Alert: Network Status Monitor daemon (rpcstat) is not running Source: AIX 7.1 Path: (left blank) Last modified by: (left blank) Last modified time:... (3 Replies)
Discussion started by: jsabo40
3 Replies

3. Infrastructure Monitoring

Searching for Saas Monitor service which monitor my servers which are sitting in different providers

Sorry if this is the wrong forum Searching for Saas Monitor service which monitor my servers which are sitting in different providers . This monitor tool will take as less CPU as possible , and will send info about the server to main Dashboard. The info I need is CPU / RAM / my servers status (... (1 Reply)
Discussion started by: umen
1 Replies
All times are GMT -4. The time now is 04:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy