[LINUX] I want to specify a file that is not a character string for logrotate, but is it impossible?

Thing you want to do

I want to specify as follows in the logrotate configuration file.


/var/log/nanika_no_service/【"aiueo"Other than logs starting with].log {

/var/log/nanika_no_service/aiueo.log {

The result of investigating

It seems impossible. Inevitably, compromise below.


/var/log/nanika_no_service/[!a]*.log {

/var/log/nanika_no_service/a*.log {


https://github.com/logrotate/logrotate/blob/master/logrotate.c https://github.com/logrotate/logrotate/blob/master/config.c

According to the source code, glob is used to search for files to rotate. So, I also read the specifications of glob, but there was no way to write "other than multiple characters", although there was a guide for wildcards "other than single characters".

That's why the logrotate.conf file specification

/var/log/nanika_no_service/【"aiueo"Other than logs starting with].log {

The conclusion so far is that it cannot be written as above. Is there a good way?


I want to rotate only one type of log under different conditions for logs in the same directory. That's why I investigated it. In the above example, ʻaiueo.log` corresponds to that.

but please wait a moment. Wouldn't it be better to write as follows without using [!]?


/var/log/nanika_no_service/*.log {

/var/log/nanika_no_service/aiueo.log {

I agree. I expected that too. But unfortunately it is NG.

The logrotate setting does not work well with duplicates. If you do the above, ʻaiueo.logwill also be included in* .log and there will be duplicate settings. Under these conditions, an error will occur at runtime, or ʻaiueo.log will also follow the setting of * .log (depending on the setting order, but forget which sequence will be what behavior). I did).

in conclusion

In this post, I investigated whether it is possible to express "other than multiple characters" in the target log specification of logrotate. Unfortunately, I haven't found a way to do it so far.

Good luck.

Recommended Posts

I want to specify a file that is not a character string for logrotate, but is it impossible?
I want to split a character string with hiragana
I want to identify the alert email. --Is that x a wildcard? ---
[Question] I want to scrape a character string surrounded by unique tags!
I tried to generate a random character string
The file edited with vim was readonly but I want to save it
I want to write an element to a file with numpy and check it.
I want to add silence to the beginning of a wav file for 1 second
I tried installing a driver for a NIC that is not recognized by Linux
I thought it would be slow to use a for statement in NumPy, but that wasn't the case.
I defined ForeignKey to CustomUser specified in AUTH_USER_MODEL in Django, but it is not referenced
I want to embed a variable in a Python string
[Ansible] Example of playbook that adds a character string to the first line of the file
I want to refute "Ruby is not cool here"
I want to randomly sample a file in Python
I want to save a file with "Do not compress images in file" set in OpenPyXL
[Linux] When you want to search for a specific character string from multiple files
I want to say that there is data preprocessing ~
I made a tool that makes it convenient to set parameters for machine learning models.
I don't want to search for high para because it is IQ1 (how to use lightgbm_tuner)
I want to convert an ISO-8601 character string to Japan time
I want to create a Dockerfile for the time being.
I want to use a wildcard that I want to shell with Python remove
Normalize the file that converted Excel to csv as it is.
I want to create a pipfile and reflect it in docker
Python vba to create a date string for creating a file name
How to input a character string in Python and output it as it is or in the opposite direction.
I want to do it with Python lambda Django, but I will stop
I tried to implement deep learning that is not deep with only NumPy
I want to tweet on Twitter with Python, but I'm addicted to it
I made an AI to judge whether it is alcohol or not!
Mayungo's Python Learning Episode 6: I tried to convert a character string to a number
I want to color a part of an Excel string in Python
I tried using eval (a, b) for Fibonacci, but it wasn't fast
I think it's a loss not to use profiler for performance tuning
I felt that mock for object is easier to see via patch.
I want to print in a comprehension
I want to build a Python environment
[Python] How to invert a character string
I want to get the path of the directory where the running file is stored.
I want to display only different lines of a text file with diff
I want to create a nice Python development environment for my new Mac
A story that sometimes does not work if pip is up to date
I just want to add scipy, but it's a messy note. Ubuntu, Python 3.
I want to create a priority queue that can be updated in Python (2.7)
I want to drop a file on tkinter and get its path [Tkinter DnD2]
When I tried to make a VPC with AWS CDK but couldn't make it
I tried to explain what a Python generator is for as easily as possible.
I want to make a music player and file music at the same time
I want to create a web application that uses League of Legends data ①
[Linux] You do not have root privileges. But I want to yum install.
I tried to make a dictionary function that does not distinguish between cases
Python program is slow! I want to speed up! In such a case ...
Library for "I want to do that" of data science on Jupyter Notebook
I tried to make OneHotEncoder, which is often used for data analysis, so that it can reach the itch.