Get the App
SLTechnology News&Howtos  ›  Servers  › 

Shell cutting log script

Shulou Source: shulou.com Published: 2022-06-02 12:33:15 11月25日 Update

Vi / etc/logrotate.d/nginx # Editing script

/ usr/local/nginx/logs/*.log / usr/local/nginx/logs/nginx_logs/*.log {

Missingok # ignores errors, such as the "log file cannot be found" error message.

Dateext # switched log files will be appended with a dash and a date in YYYYMMDD format. Without this configuration item, a decimal point and a numeric sequence number will be appended.

Notifempty # if the log file is empty, no cutting is performed.

Daily # cut logs on a daily basis. Available value month: monthly week: weekly year: yearly

Rotate 3 # keeps log records for the last 3 days

Sharedscripts # scripts that run only once for the entire log group

The commands specified in postrotate # will be executed

If [- f / usr/local/nginx/logs/nginx.pid]; then

Kill-USR1 `cat / usr/local/nginx/logs/ nginx.pid`

Fi

Endscript

}

Tags: Logs files scripts errors appends commands decimal points serial numbers numbers dates formats horizontal lines toggles prompts runs configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker OPPO Reno Redmi MariaDB Shulou Information