473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to rotate a log file when it reaches a particular size

14
Hello
i want to rotate a log file called test.log, the rotation must be done when the file reaches a particular size say 100 kb. i know that for weekly and daily we just write weekly / daily but
the problem is that i don't know the command syntax that make the rotation happens when my file reaches 100 kb.
note: i have opened /etc/logrotate.d/rsyslog and added the directory in which my log file resides.
please help quickly..
Mar 19 '13 #1

✓ answered by sicarie

It sounds like you're already on the right path - I'd use logrotate set up like one of the many examples here.

It sounds like there is a size option, so if you set the entry as (inside logrotate file):
Expand|Select|Wrap|Line Numbers
  1. /path/to/test.log {
  2.     size 100k
  3.     create 0700 root root #or whatever user you want
  4.     rotate 7 #or however many you want to keep
  5. }
  6.  

3 1862
sicarie
4,677 Expert Mod 4TB
It sounds like you're already on the right path - I'd use logrotate set up like one of the many examples here.

It sounds like there is a size option, so if you set the entry as (inside logrotate file):
Expand|Select|Wrap|Line Numbers
  1. /path/to/test.log {
  2.     size 100k
  3.     create 0700 root root #or whatever user you want
  4.     rotate 7 #or however many you want to keep
  5. }
  6.  
Mar 20 '13 #2
Nosia
14
sicarie thank you very much.......
yes i was on the right way and i tried the syntax "size 100k"
and it had to work but i didn't restart the service to recognize the change i've made in rsyslog file, that is why the service did not rotate my log file...and at that moment i thought it may be because of syntax error in my file...
i am working under ubuntu 12.4 and it doesn't have a service of kind logrotate so the user have to force the confegration file to read the change..
Mar 20 '13 #3
sicarie
4,677 Expert Mod 4TB
Ah, good catch - glad you figured it out!
Mar 20 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt | last post by:
The following code won't work, because onchange event is not trigger when drop down size = 1. But if I make the size="2" or greater, then it will work. Is that true? please advise. thanks!! ...
7
by: black | last post by:
hi all~ in my .py file there are a few print to trace out some message and i wonder if we can save it into a specified file when that script get running. if so, i may just check that file to c...
11
by: Danke | last post by:
I have a compiled file (.mde) and need to replace the file. I use Access 97 and SQL-server. I have about 150 users. I have made a shortcut to the startmenu for this file. Its impossible to replace...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
2
by: Sacha Korell | last post by:
How would I check for an end of file when parsing a text file using the StreamReader object? I would like to do something like this: '******************************** Dim objStreamReader As...
1
by: mohan21_kumar | last post by:
Hi, How to Save images in ms word file when it is downloaded from asp.net application. I have used the following code to convert the html page into ms word file. but i'm not able to save the...
2
by: zacks | last post by:
I have an application that stores its configuration file in the user's Local Application special folder in a subfolder COMPANYNAME \PRODUCTNAME. The application creates the file the first time the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.