LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 07-24-2015, 03:14 AM   #1
spande
LQ Newbie
 
Registered: Jul 2015
Posts: 6

Rep: Reputation: Disabled
Issue regarding Daily Rotating Log file


Hello All,

I have to Rotate one of my log file (test_cron.log) which is under /root/ on daily basis , so for that i have made one new file in under /etc/logrotate.d/soc_logs.
also added entry in crontab as : */1 * * * * /usr/sbin/logrotate /etc/logrotate.d/soc_logs
But it does not rotate daily.
and write code as follows.

/root/test_cron.log
{
compress
daily
size 20k
rotate 7
dateext
create 0600 root root

}

Also i want 7 days backup of that log file and if file size increased by say for example 20k then also it must be make new file with date extension.

Thanks in advance..
Santosh Pande..
 
Old 07-24-2015, 01:27 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Are you saying it doesn't check for rotation daily, or saying that you don't see the file rotated daily? The difference there is if you don't have the -f or --force option in your call to logrotate, then it won't force rotation and instead rely on the size qualifier of 20k. Have any of these files exceeded 20k prior to the daily call to logrotate and then not been rotated? Or have none of these files yet reached that size?

If you do invoke logrotate with the -f or --force option it will force rotation whether or not it feels rotation of a log file is required.
 
1 members found this post helpful.
Old 07-24-2015, 01:32 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
...additionally you can debug things and see for yourself running it as '/usr/sbin/logrotate -d /etc/logrotate.d/soc_logs;'. Do post the output if unsure.
*Ow, and there's no good reason to create and keep log files in the /root directory IMHO.
 
1 members found this post helpful.
Old 07-24-2015, 01:36 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by unSpawn View Post
...additionally you can debug things and see for yourself running it as '/usr/sbin/logrotate -d /etc/logrotate.d/soc_logs;'. Do post the output if unsure.
*Ow, and there's no good reason to create and keep log files in the /root directory IMHO.
Excelling points. Right, not in /root. And you can manually run logrotate from the command line with the -d option as well as the -f option and see how it deals with your log file. That should assist you for when you're ready to let the cron job run it daily.
 
1 members found this post helpful.
Old 07-25-2015, 10:36 AM   #5
ember1205
Member
 
Registered: Oct 2014
Posts: 176

Rep: Reputation: 16
Generally, there is a file in /etc/cron.daily called logrotate that contains the "instructions" to run the program. You add your configuration file to the /etc/logrotate.d directory and you're done.

Double-check the permissions to the file you created, the permissions to the file you're attempting to run logrotate against, and verify that the size is large enough to trigger a rotate event.
 
1 members found this post helpful.
Old 07-27-2015, 04:11 AM   #6
spande
LQ Newbie
 
Registered: Jul 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
thank u all..
issue got resolved..

Regards,
Santosh Pande..
 
Old 07-27-2015, 02:23 PM   #7
ember1205
Member
 
Registered: Oct 2014
Posts: 176

Rep: Reputation: 16
Glad you're up and working now.

If you wouldn't mind, please post some details of what you did to correct it. Others may come across your thread in the future and be interested in knowing what ended up correcting the problem so they can try it on their own system.
 
  


Reply



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
rotating apache logs.....looking for a good script to delete old log file ringding Linux - Server 6 04-25-2020 12:59 PM
Logrotate rotating daily when should rotate weekly nanda_martins Linux - Server 14 03-29-2010 12:24 PM
creating a script to email daily log file sittnduck Linux - Server 4 07-15-2008 08:59 PM
rotating cruisecontrol.log tkubaska Linux - General 2 06-24-2007 02:17 PM
LXer: Rotating Linux Log Files LXer Syndicated Linux News 0 06-07-2006 06:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 08:27 PM.

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