System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

collect log files based on date

 
SOLVED
Go to solution
S.S.
Super Advisor

collect log files based on date

Hi,

I want to collect the log files based on particular date. How can i collect them.
Can someone help me.

Thanks!
3 REPLIES
Elko
Frequent Advisor

Re: collect log files based on date

You can try this :

find /path_to_files -iname "*.file_extension" -mtime -period_of_time -print

where is :
iname , i means , not to pay attention on big/small letters in name

-period_of_time --period of time you are want to search

So if you want to look for txt files changed in last 15 days and in /home directory command would be

find /home -iname "*.txt" -mtime -15 -print

Hope this helps
/home/BIH/Sarajevo
S.S.
Super Advisor

Re: collect log files based on date

Hi,

I want to do for the /var/log/messages. How can i collect log files for yesterday only.

Thanks!
Ralph Grothe
Honored Contributor
Solution

Re: collect log files based on date

Usually, on Linux one has logrotate working.

If nothing else is defined in
/etc/logrotate.d/syslog
then the global rotation scheme as defined in
/etc/logrotate.conf holds which is "daily".

Then check your crontab when the daily jobs are executed.

# grep daily /etc/crontab
02 4 * * * root run-parts /etc/cron.daily
# ls -l /etc/cron.daily/logrotate
-rwxr-xr-x 1 root root 180 Jul 13 2005 /etc/cron.daily/logrotate

So, on my sample box rotation starts daily at 04:02

Now, depending how many rotation cycles or generations are defined in either
/etc/logrotate.d/syslog or
/etc/logrotate.conf
that many days back of syslog (messages) you will have before older rolled files will be overwritten with newer ones.
For older logs you would have to restore them from your backups.




Madness, thy name is system administration