Can Logrotate be use in C?

635 Views Asked by At

I'm a newbie on linux and I was planning to use logrotate so that my log files which generate inside a radio file system, would not getting larger size and cause any memory issue.

but as can see from below, this configuration is set at logrotate.conf file in linux, then I am confused and wonder is it possible to add this thing as a "coding style" in my C files so that it work on my radio which is running Linux system.

The radio don't have this logrotate thing under /etc/logrotate.d path after all. I also unable to install any logrotate or execute the command "man logroate", it tells : no manual entry for 'logrotate'.

/var/logs/*.log {
    hourly
    missingok
    rotate 24
    compress
    create
}

Can it be called like normal function such as fclose() or fopen() in .C files?

If it can be used in C files, what is the correct way to configure the parameter?

1

There are 1 best solutions below

0
On

I think you misinterpreted how logrotate work: It only work with files created by service/application on host machine.

For example on your linux machine you are running mailing server postfix (base on config you posted):

  1. Postfix service filling log file /var/log/postfix.log
  2. Logrotate take every hour postfix.log and create compressed file postfix.1
  3. Increment number of already existing archive files
  4. Logrotate keep 24 compressed files (= 1 day)

In you case you have to setup application logging to save log files and then you can apply logrotate to it.

Logrotate man page can be found here