S
S
Sergey Savostin2014-08-02 18:17:21
linux
Sergey Savostin, 2014-08-02 18:17:21

How to properly organize logrotate in your service?

With Apache / MySQL / Nginx, etc., everything is clear.
I have my own service (C++ application) that writes the log to a file.
How to properly connect logrotate to it?
As I understand it, you need to close the file (i.e., process some kind of signal?), then logrotate will process it and then open it (again, some kind of signal?).
Does anyone have a simple example, you can schematic.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sim3x, 2014-08-03
@savostin

The log is just a text file, it will not get corrupted by the fact that a couple of lines will break
just man logrotate and configure the config for yourself

D
Disassociative, 2014-08-02
@Disassociative

Use supervisord, don't bother with daemonization and logs will be displayed to you as you ask.

A
AxisPod, 2014-08-06
@AxisPod

Linux allows you to rename a file, while the service continues to write to it. The only thing that needs to be implemented is reopening the file, logrotate renames it, and then sends a signal to the application, for example SIGUSR1, just reopen the log file and continue writing. Nothing is broken anywhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question