filelogger
filelogger -c config.rc >& error.log
This program analyses changes in files and directories in monitored directory trees (@dirList) between consecutive runs of the program and appends a report to a file specified by $baseLog. It does so by storing the state of the files and directories in @dirList in a file specified by $lastLog, each time the program runs. Whereas the file specified by $baseLog is meant to be examined by the user, the file specified by $lastLog is for internal consumption only. The program reports which files and directories have been created, deleted or modified. Changes to the following attributes of files are monitored: mode, user, group, size, and mtime.
Configuration information is provided in a separate file that must be specified using the -c command-line option, e.g. filelogger -c filelogger.rc
The following is a sample configuration file:
######################################################################## # # # CONFIGURATION # # # ########################################################################
# Used to identify configuration in log file $reportId = "Ardan Patwardhan";
# Log file to contain state of monitored directories # Meant only to be used internally by the program $lastLog = "lastLog.log";
# Base log file - All info about changes to monitored files will be # appended to this file. If it does not exist, it will be created. $baseLog = "baseLog.log";
# Directories to monitor
@dirList = ("/f03/image/tbsv",
"/f07/image/tbsv",
"/f08/ardan",
"/f10/ardan",
"/f11/Image/ardan",
"/f11/Image/marc",
"/f13/ardan",
"/f14/ardan",
"/f15/ardan",
"/f15/mount",
"/f15/patches",
"/wolf1/ardan",
"/wolf9/ardan",
"/disk1/ardan",
"/disk1/Image/ardan",
"/usr/users/ardan");
# List of patterns specifying files and directories that should be
# excluded. Use Perl regular expression syntax
@excludeList = ('~$', # Emacs old files
'.saves-', # Emacs .saves files
'#\w+(\.\w+)*#$', # Emacs backup files
'/core$', # Core dumps
'junk', # Junk files and directories
);
The best way to run this script is to have it run periodically by adding a crontab entry. The following is an example crontab entry that runs every night at 1:10:
10 1 * * * /usr/users/ardan/perl/filelogger -c/usr/users/ardan/filelogger.rc >& /usr/users/ardan/error.log
The following is a sample from a base log file:
FILELOGGER REPORT BEGIN Prepared for Ardan Patwardhan on 2002/1/3 at 15:09:53 Source size(bytes) : 23907240
Modified files:
Number : 2 Size (bytes): 35215
Mode Date Time Size Owner Group File-name
==========================================================================================
-rw-r--r-- 20020103 15:09:45 21017 ardan users /usr/users/ardan/history.log
-rwxr-xr-x 20020103 15:09:25 14198 ardan users /usr/users/ardan/perl/filelogger
Deleted files:
Number : 1 Size (bytes): 512
Mode Date Time Size Owner Group File-name
==========================================================================================
drwxr-xr-x 20020103 12:25:11 512 ardan users /usr/users/ardan/tmp1
FILELOGGER REPORT END
Copyright 2001-2002 by Ardan Patwardhan. All Rights Reserved.
This software is provided on an 'as is' basis and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
Script for monitoring specified directory trees for changes in files and directories.
File::Find
dec_osf (tested) Any Unix or Linux OS (not tested)
Unix/System_administration