473,326 Members | 2,173 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,326 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 1857
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.