LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-23-2019, 03:41 PM   #1
vasim38
LQ Newbie
 
Registered: Apr 2018
Posts: 12

Rep: Reputation: Disabled
Log Rotation related question


i need to rotate logs daily and i have script working fine.My issue is after log rotation i want different files to be compressed in one single gz. How to achieve this.

eg. /var/log/tmp
-rw-r--r-- 1 root root 0 Jan 23 21:19 abc.log
-rw-r--r-- 1 root root 0 Jan 23 21:19 cdf.log

after log rotation i want both files to be compressed in single file. Can you help me here ?
 
Old 01-23-2019, 03:57 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
There are many ways. You can concatenate them to a single file then compress that:
Code:
cat abc.log cde.log | gzip -c > abcde.log.gz
If you need to recover the filenames after decompression, create a tar:
Code:
tar czf abcde.tgz abc.log cde.log

Last edited by berndbausch; 01-23-2019 at 04:00 PM.
 
1 members found this post helpful.
Old 01-23-2019, 04:18 PM   #3
vasim38
LQ Newbie
 
Registered: Apr 2018
Posts: 12

Original Poster
Rep: Reputation: Disabled
berndbausch : I am asking while executing logrotate script and not in general
 
Old 01-23-2019, 07:31 PM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
This shows how useful it can be to provide more context to questions.

Unfortunately I don't have an answer.
 
Old 01-23-2019, 08:14 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,704

Rep: Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897Reputation: 5897
logrotate does have a postrotate option to run a shell script after log rotation.

https://www.thegeekstuff.com/2010/07...tate-examples/
 
1 members found this post helpful.
Old 01-23-2019, 08:31 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by berndbausch View Post
This shows how useful it can be to provide more context to questions.

Unfortunately I don't have an answer.
I thought that was an excellent answer. Two ways to do what the OP asked. Just include either in their script....
 
  


Reply

Tags
log, logrotate



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Log parsing but issue with log rotation Rohant Linux - Server 1 05-30-2013 09:09 PM
[SOLVED] Log rotation of log files in different directories mahi_nix Linux - Server 7 02-19-2013 05:33 AM
Syslog-ng messages.log log rotation Iyyappan Linux - Server 3 09-16-2012 11:10 AM
How to change Debian log rotation of syslog and daemon.log onmountain Linux - Newbie 2 07-31-2008 02:27 AM
Log Rotation for snort log does not seem to be working CentOS4.5 JasonKretzer Linux - Security 3 06-25-2007 12:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration