Get the App
SLTechnology News&Howtos  ›  Servers  › 

Nginx log slicing script

Shulou Source: shulou.com Published: 2022-06-02 08:32:04 11月18日 Update

#! / bin/bashLogs_path='/var/log/nginx' # define the log path yesterday= `date-d "yesterday" +% F` # get yesterday's date cd ${Logs_path} # cut log if [- f access.log]; then cp {, "${date}" _} access.log: > access.log # clear the coquettish operation fiif of source access.log content [- f error.log] Then cp {, "${yesterday}" _} error.log: > error.log # clear the source error.log content of the coquettish operation fifind. -type f-name "* .log"-mtime + 7-delete # delete all logs from 7 days ago

Tags: Log content date path script Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple Shulou Technology Docker Shulou Information