Archiving a log file on monthly basis


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Archiving a log file on monthly basis
# 1  
Old 06-02-2014
Archiving a log file on monthly basis

OS : RedHat Linux 6.2
Shell : Bash

Our application write messages, warnings,..etc to the following log file .

/app/cms/diagnostics/logs/cms_messages.log

This file has become huge now. I want this file to be archived on monthly basis using a small shell script.

ie. On the 1st day of every month, cms_messages.log should be archived like
Code:
cms_messages_<previousMonth>_<Year>.log

Eg: On 1st June 2014, the current log file should be archived like
Code:
cms_messages_May_2014.log

and a fresh cms_messages.log should be created in the location /app/cms/diagnostics/logs ?

How can I do this ?

Last edited by omega3; 06-02-2014 at 11:49 AM..
# 2  
Old 06-02-2014
I think this has been covered, at least in part, many times in these fora. Show us what you have tried so far.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Archiving or removing few data from log file in real time

Hi, I have a log file that gets updated every second. Currently the size has grown to 20+ GB. I need to have a command/script, that will try to get the actual size of the file and will remove 50% of the data that are in the log file. I don't mind removing the data as the size has grown to huge... (8 Replies)
Discussion started by: Souvik Patra
8 Replies

2. Shell Programming and Scripting

Splitting XML file on basis of line number into multiple file

Hi All, I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom. from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Discussion started by: ajju
14 Replies

3. UNIX for Dummies Questions & Answers

Tracking the script(.sh) files triggered on daily or monthly basis from source

Hi Gurus, Is there any solution for tracking the script(.sh) files triggered on daily or monthly basis from source - Datastage (Routines) Needs to find out if this scripts are running on daily just want to know that is there anything to track Thanks in Advance (2 Replies)
Discussion started by: SeenuGuddu
2 Replies

4. Shell Programming and Scripting

Separate a file on the basis of timestamp

hi, I have a log file which contains data for last 7 seven days. I want to copy all the data for 6 days in one file and keep only the data for today in that log file and mail that log file containing today's data. Log file is in this format Time: 120529 10:51:08 User@Host: local @ ... (4 Replies)
Discussion started by: arijitsaha
4 Replies

5. Shell Programming and Scripting

What extra Parameters I can use for archiving log files

Hello All, I have developed a script which takes following parameter from the input file to archive log files 1)Input Path 2)File pattern(*.csv) 3)Number of days(+1) Following is the algorithm of my script Read the input file go to that path and search for particular n days older... (3 Replies)
Discussion started by: mitsyjohn
3 Replies

6. Shell Programming and Scripting

FTP a file on Hourly basis

Hi, I have to upload a file test_201105281100.txt to a ftp location. The files will be created on hourly basis like test_201105281100.txt, test_201105281200.txt & so on. After a file is uploaded successfully, I need to rename the file as test_201105281100.success & if it is not uploaded... (11 Replies)
Discussion started by: SunilB2011
11 Replies

7. Shell Programming and Scripting

Split one file to Multiple file with report basis in unix

Hi, Please help on this. i want split the below file(11020111.CLT) to more files with some condition. :b: 1) %s stating of the report 2) %e ending of the report example starting of the report: %sAEGONCA| |MUMBAI | :EXPC|N|D ending of the report %eAEGONCA| |MUMBAI | :EXPC 3)so the... (10 Replies)
Discussion started by: krbala1985
10 Replies

8. Shell Programming and Scripting

Shell script for log archiving

I have an nfs mount /logfile/project mounted on several of my application server machines. I have 5 jvms running on each machine and I have several machines. the jvms logs are created and rotated every day so it will look like /jvm1/logs/server.log.2010-10-27 /jvm2/logs/server.log.2010-10-27... (3 Replies)
Discussion started by: gubbu
3 Replies

9. UNIX for Advanced & Expert Users

Autosys JOB on monthly basis

Dear All, Can someone tell me how do I setup autosys job where it needs to execute on monthly basis that too on 1st day of the month. Thanks. (3 Replies)
Discussion started by: shahnazurs
3 Replies
Login or Register to Ask a Question