Sponsored Content
Top Forums Shell Programming and Scripting find files from the past 7 days Post 302244189 by otheus on Tuesday 7th of October 2008 11:44:30 AM
Old 10-07-2008
There may be other wazs, but here's what I'd do. Install "logwatch". Let's say it installs into /usr/share/logwatch. Then make a little perl-script:

Code:
#!/usr/bin/perl
use lib "/usr/share/logwatch/lib";
use Logwatch ':dates';

$ENV{"LOGWATCH_DATE_RANGE"}="since -7 days";
my $SearchDate = TimeFilter('%b %d %H:%M');

while (<>) {
   print if m/\b$SearchDate\b/o;
}

Then do perl <scriptname> <filename>

You should have what you are looking for.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies

2. UNIX for Dummies Questions & Answers

creating a CSV file for past 7 days

I have a requirement which will select the files with a specific naming convention which got created in past 7 days in a specific directory.Lets say the directory is /data/XYZ and the file names follow the below nomenclature like Daily_File*.txt I just need to create one CSV file which will... (12 Replies)
Discussion started by: dr46014
12 Replies

3. Shell Programming and Scripting

How to find a date which is 7 days past when given current date

hii all. I have to get the date of the 7th day past from the current date. if i give the current date as sep 3 then i must get the date as 27th of august. can we get the values from the "cal" command. cal | awk '{print $2}' will this type of command work. actually my need is if today is... (17 Replies)
Discussion started by: ladtony
17 Replies

4. Shell Programming and Scripting

Find last 2 days files.

Need to cpy those files which are created or modified in last 2 days. bash$ ll -lrt total 184 drwxr-xr-x 2 ons dce 256 Oct 12 06:58 files -rw-r--r-- 1 ons dce 4313 Oct 14 06:06 cab.ksh -rw-r--r-- 1 ons dce 6 Oct 14 07:03 Code.txt... (2 Replies)
Discussion started by: saluja.deepak
2 Replies

5. Shell Programming and Scripting

what is the find to command to find the files created last 30 days

what is the find to command to find the files created last 30 days (5 Replies)
Discussion started by: rajkumar_g
5 Replies

6. Shell Programming and Scripting

Listing files of PAST 7 days and concatenate it...

Hi All, I want to list file of LAST 7 days acc. to its modified date and then concatinate. I have following piece of code.. For concatenate cat file1 file2 >> Output (For concatinating) find . -mtime -7 -exec basename {} \; (list past files but it is including . file also) Plz... (4 Replies)
Discussion started by: vivek1489
4 Replies

7. UNIX and Linux Applications

From past 10 days my one job is taking lots of time

One of my job is taking long running time. I need to identify from the unix log file can you please help how to troubleshoot. (1 Reply)
Discussion started by: Nsharma3006
1 Replies

8. UNIX for Dummies Questions & Answers

Find command to get the modified files past 2 hours

Hello, How to get the modified/created files past 2 hours in Solaris with find command? Thank you. (7 Replies)
Discussion started by: balareddy
7 Replies

9. Shell Programming and Scripting

Should pick latest file within past 3 days using UNIX script and perform steps in message below.

Hi , Can anyone help me how do perform below requirement in unix. Step1:we will receive multiple files weekly with same name(as below) in a folder(In folder we will have other files also def.dat,ghf.dat) Filenames: 1) abc_20171204_052389.dat 2)abc_20171204_052428.dat DON'T modify... (23 Replies)
Discussion started by: sunnykamal59
23 Replies
LOGWATCH(8)							   User Manuals 						       LOGWATCH(8)

NAME
logwatch - system log analyzer and reporter SYNOPSIS
logwatch [--detail level ] [--logfile log-file-group ] [--service service-name ] [--mailto address ] [--archives] [--range range ] [--debug level ] [--filename file-name ] [--logdir directory ] [--hostname hostname ] [--hostformat host based options ] [--output output-type ] [--format report format ] [--encode encoding to use ] [--numeric] [--version] [--help|--usage] DESCRIPTION
Logwatch is a customizable, pluggable log-monitoring system. It will go through your logs for a given period of time and make a report in the areas that you wish with the detail that you wish. Logwatch is being used for Linux and many types of UNIX. OPTIONS
--detail level This is the detail level of the report. level can be a positive integer, or high, med, low, which correspond to the integers 10, 5, and 0, repectively. --logfile log-file-group This will force Logwatch to process only the set of logfiles defined by log-file-group (i.e. messages, xferlog, ...). Logwatch will therefore process all services that use those logfiles. This option can be specified more than once to specify multiple logfile- groups. --service service-name This will force Logwatch to process only the service specified in service-name (i.e. login, pam, identd, ...). Logwatch will there- fore also process any log-file-groups necessary to process these services. This option can be specified more than once to specify multiple services to process. A useful service-name is All which will process all services (and logfile-groups) for which you have filters installed. --mailto address Mail the results to the email address or user specified in address. This option overrides the --print option. --range range You can specify a date-range to process. Common ranges are Yesterday, Today, All, and Help. Additional options are listed when invoked with the Help parameter. --archives Each log-file-group has basic logfiles (i.e. /var/log/messages) as well as archives (i.e. /var/log/messages.? or /var/log/mes- sages.?.gz). When used with "--range all", this option will make Logwatch search through the archives in addition to the regular logfiles. For other values of --range, Logwatch will search the appropriate archived logs. --debug level For debugging purposes. level can range from 0 to 100. This will really clutter up your output. You probably don't want to use this. --filename file-name Save the output to file-name instead of displaying or mailing it. --logdir directory Look in directory for log subdirectories or log files instead of the default directory. --hostname hostname Use hostname for the reports instead of this system's hostname. In addition, if HostLimit is set in the logwatch.conf configuration file (see MORE INFORMATION, below), then only logs from this hostname will be processed (where appropriate). --numeric Inhibits additional name lookups, displaying IP addresses numerically. --usage Displays usage information --help same as --usage. FILES
/usr/share/logwatch/ This directory contains all the perl executables and configuration files shipped with the logwatch distribution. /etc/logwatch This directory contains local configuration files that override the default configuration. See MORE INFORMATION below for more information. EXAMPLES
logwatch --service ftpd-xferlog --range all --detail high --print --archives This will print out all FTP transfers that are stored in all current and archived xferlogs. logwatch --service pam_pwdb --range yesterday --detail high --print This will print out login information for the previous day... MORE INFORMATION
The directory /usr/share/doc/logwatch-* contains several files with additional documentation: HOWTO-Customize-LogWatch Documents the directory structure of Logwatch configuration and executable files, and describes how to customize Logwatch by over- riding these default files. LICENSE Describes the License under which Logwatch is distributed. Additional clauses may be specified in individual files. README Describes how to install, where to find it, mailing lists, and other useful information. AUTHOR
Kirk Bauer <kirk@kaybee.org> http://www.kaybee.org/~kirk ftp://ftp.kaybee.org/pub/redhat/RPMS Linux October 2005 LOGWATCH(8)
All times are GMT -4. The time now is 11:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy