Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check a files Modified date and email if it has changed [closed]

Tags:

linux

solaris

I am look for a bash script that will check if a file has been modified in the last hour and email an alert if it has been modified. This script will be used in Solaris and Ubuntu. I am sure it's not hard, but I am not a Linux admin. Can someone please help?

like image 939
SueS Avatar asked Jan 04 '13 20:01

SueS


People also ask

How can I tell when a file was last modified?

Windows file propertiesRight-click the file and select Properties. In the Properties window, the Created date, Modified date, and Accessed date is displayed, similar to the example below.

Does date modified change when I open a file?

modification date does NOT change on open or close.


1 Answers

How about this?

#!/bin/bash

[[ -z `find /home/spatel/ -mmin -60` ]]

if [ $? -eq 0 ]
then
    echo -e "nothing has changed"
else
    mail -s "file has been changed" [email protected]
fi

Put this script in hourly cron job

01 * * * * /path/to/myscript 
like image 52
Satish Avatar answered Oct 01 '22 07:10

Satish