Sponsored Content
Operating Systems Linux Red Hat Logrotate to delete file which has date stamp Post 302819939 by bobby320 on Tuesday 11th of June 2013 05:14:13 PM
Old 06-11-2013
Logrotate to delete file which has date stamp

Hello, can someone please suggest how to create an logrotate for this scenario. Need to delete all log file which are created more than 30 days ago, and all the log file have date stamp on it.

I dont want to create a cron job for this task.
here is the example
Code:
-rw-r--r-- 1 tomcat tomcat    49203 May 18 22:22 access.2013-05-18.log
-rw-r--r-- 1 tomcat tomcat    42702 May 19 23:59 access.2013-05-19.log
-rw-r--r-- 1 tomcat tomcat   396889 May 20 23:21 access.2013-05-20.log
-rw-r--r-- 1 tomcat tomcat   380026 May 21 23:26 access.2013-05-21.log
-rw-r--r-- 1 tomcat tomcat   255419 May 22 23:37 access.2013-05-22.log
-rw-r--r-- 1 tomcat tomcat   412441 May 23 23:12 access.2013-05-23.log
-rw-r--r-- 1 tomcat tomcat   236075 May 24 23:54 access.2013-05-24.log
-rw-r--r-- 1 tomcat tomcat    55490 May 25 23:55 access.2013-05-25.log
-rw-r--r-- 1 tomcat tomcat    41054 May 26 23:50 access.2013-05-26.log
-rw-r--r-- 1 tomcat tomcat   258924 May 27 23:18 access.2013-05-27.log
-rw-r--r-- 1 tomcat tomcat   258924 May 27 23:18 access.log

Thanks,
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File date and time stamp

I have to capture the creation date and time stamp for a file. The ls command doesn't list all the required information. I need year, month, day, hour, minute and second. Any ideas... (1 Reply)
Discussion started by: Xenon
1 Replies

2. Shell Programming and Scripting

creating a new file with date stamp

Hi, can any one tell me how to achieve this...I will input the path and file name and it should rename it to current date and time... this is what I tried... #! /usr/bin/sh set -x cd /info_stg/vul/Scripts TODAY_DATE_TIME=`date +%Y%m%d%H%M%S` IN_FILE_PATH=`cat file.txt | awk -F, '{... (2 Replies)
Discussion started by: mgirinath
2 Replies

3. Shell Programming and Scripting

Date Stamp on new file

Dear Gurus, I'm trying to move a number of files from one directory to another directory with a new date stamp. This is my script: #! /bin/csh Today_Date=`date +%Y%M%D` mv /usr/TRS/data/TS* /usr/TRS/backup/TS*.${Today_Date} when i run the script i'm getting the following errors: mv:... (14 Replies)
Discussion started by: lweegp
14 Replies

4. UNIX for Dummies Questions & Answers

How to Zip the files from date Stamp to end date Stamp

Hi, I need to zip the list of files using from date Stamp to end date Stamp, How can I filter and make FromDate_EndDate.gzip? any idea? (1 Reply)
Discussion started by: redlotus72
1 Replies

5. UNIX for Dummies Questions & Answers

Need to delete the files based on the time stamp of the file

Hi Everyone, I want to delete some files in a path based on the time stamp of the file that is i want to delete the file once in a month. Can any one help me on this? Thanks in advance (2 Replies)
Discussion started by: samudha
2 Replies

6. Shell Programming and Scripting

copying a file without changing date stamp.

Hi, I am using the below copy command, to copy the file sbn to sbn1, cp sbn sbn1 but its changing the date stamp of file sbn1, but i dont want to change the date stamp of sbn1. Could you please help me out in this. (3 Replies)
Discussion started by: shivanete
3 Replies

7. UNIX for Dummies Questions & Answers

sed a file and maintain date stamp and permissions

I need to alter a file. I'm using sed then passing output to temp file then using touch -r to maintain the date but the permissions do not get preserved How can I sed a file and maintain date and permissions currently it's preserving the date but the permissions revert back to the... (3 Replies)
Discussion started by: andyatit
3 Replies

8. Shell Programming and Scripting

Set date and time stamp of one file to another

Hi I use "touch -t xxxxxxxx" command to set date/time stamp of a file. My requirement is to read the date/time stamp of a file and apply it to another file. Is there anyway to do it simple instead of manually taking date/stamp of first file? TIA Prvn (2 Replies)
Discussion started by: prvnrk
2 Replies

9. Shell Programming and Scripting

If(Condition) Rename a file with (Date+Time) Stamp

Hi! Please see our current script: #!/usr/bin/ksh if (egrep "This string is found in the log" /a01/bpm.log) then mailx -s "Error from log" me@email.com, him@email.com </a01/bpm.log fi To the above existing script, we need to add the following change: 1) After finding the string,... (7 Replies)
Discussion started by: atechcorp
7 Replies

10. UNIX for Beginners Questions & Answers

Adding Date Stamp To File Name With sed

trying to add a date stamp to the name of a file with sed. can't seem to comment out the date command so that sed does not only see it as a literal text string this is what I'm trying ls file.txt | sed 's/file.txt/file\/`date`\/.txt/g'but it's giving this file/`date`/.txtlooking for something... (1 Reply)
Discussion started by: jimmyf
1 Replies
SAVELOG(8)						      System Manager's Manual							SAVELOG(8)

NAME
savelog - save a log file SYNOPSIS
savelog [-m mode] [-u user] [-g group] [-t] [-p] [-c cycle] [-l] [-j] [-J] [-1 .. -9] [-C] [-d] [-l] [-r rolldir] [-n] [-q] [-D dateformat] file ... DESCRIPTION
The savelog command saves and optionally compresses old copies of files. Older versions of file are named: file.<number><compress_suffix> where <number> is the version number, 0 being the newest. Version numbers > 0 are compressed unless -l prevents it. Version number 0 is not compressed because a process might still have file opened for I/O. Only cycle versions of the file are kept. If the file does not exist and -t was given, it will be created. For files that do exist and have lengths greater than zero, the following actions are performed: 1) Version numbered files are cycled. Version file.2 is moved to version file.3, version file.1 is moved to version file.2, and so on. Finally version file.0 is moved to version file.1, and version file is deleted. Both compressed names and uncompressed names are cycled, regardless of -l. Missing version files are ignored. 2) The new file.1 is compressed unless the -l flag was given. It is changed subject to the -m, -u, and -g flags. 3) The main file is moved to file.0. 4) If the -m, -u, -g, -t, or -p flags are given, then an empty file is created subject to the given flags. With the -p flag, the file is created with the same owner, group, and permissions as before. 5) The new file.0 is changed subject to the -m, -u, and -g flags. OPTIONS
-m mode chmod the log files to mode, implies -t -u user chown log files to user, implies -t -g group chgrp log files to group, implies -t -c cycle Save cycle versions of the logfile (default: 7). The cycle count must be at least 2. -t touch new logfile into existence -l don't compress any log files (default: do compress) -p preserve owner, group, and permissions of logfile -j compress with bzip2 instead of gzip -J compress with xz instead of gzip For xz no strength option is set, and xz decides on the default based on the total amount of physical RAM. Note that xz can use a very large amount of memory for the higher compression levels. -1 .. -9 compression strength or memory usage (default: 9, except for xz) -C force cleanup of cycled logfiles -d use standard date for rolling -D dateformat override date format, in the syntax understood by the date(1) command -r use rolldir instead of . to roll files -n do not rotate empty files -q be quiet BUGS
If a process is still writing to file.0, and savelog moves it to file.1 and compresses it, data could be lost. SEE ALSO
logrotate(8) Debian 30 Dec 2017 SAVELOG(8)
All times are GMT -4. The time now is 08:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy