#debug测试 -d, --debug Don't do anything, just test (implies -v)
logrotate -d configfile
示例
1、列出多个文件,统一配置策略
#Please note:
#nocreate and copytruncate in configuration file are mutually exclusive and can't be configured at the same time,otherwise nocreate have no effect
#create and copytruncate in configuration file are mutually exclusive and can't be configured at the same time,otherwisecreate have no effect
/var/log/startup.log
/var/log/boot.log
/var/log/backup_conf.log
/var/log/cloud-init-output.log
/var/log/cloud-init.log
/var/log/daemon.log
/var/log/cron.log
/var/log/kern.log
/var/log/syslog
/var/log/unused.log
/var/log/sysmonitor.log
/var/log/tuned/*.log
/var/log/wtmp
/var/log/btmp
{
missingok
compress
notifempty
copytruncate
rotate 10
size +4000k
}
# Logrotate file for psacct RPM
/var/account/pacct {
compress
delaycompress
notifempty
daily
rotate 31
create 0600 root root
postrotate
if /usr/bin/systemctl --quiet is-active psacct.service ; then
/usr/sbin/accton /var/account/pacct | /usr/bin/grep -v "Turning on process accounting, file set to '/var/account/pacct'." | /usr/bin/cat
fi
endscript
}
4、mariadb
/var/log/mariadb/mariadb.log {
create 600 mysql mysql
notifempty
daily
rotate 3
missingok
compress
postrotate
# just if mysqld is really running
if [ -e /run/mariadb/mariadb.pid ]
then
kill -1 $(</run/mariadb/mariadb.pid)
fi
endscript
}
A positional parameter is a parameter denoted by one or more digits, other than the single digit 0. Positional parameters are assigned from the shell’s arguments when it is invoked, and may be reassigned using thesetbuiltin command. Positional parameterNmay be referenced as${N}, or as$NwhenNconsists of a single digit. Positional parameters may not be assigned to with assignment statements. Thesetandshiftbuiltins are used to set and unset them (seeShell Builtin Commands). The positional parameters are temporarily replaced when a shell function is executed (seeShell Functions).
If parameter is ‘@’, the result is length positional parameters beginning at offset. A negative offset is taken relative to one greater than the greatest positional parameter, so an offset of -1 evaluates to the last positional parameter. It is an expansion error if length evaluates to a number less than zero.
The following examples illustrate substring expansion using positional parameters:
后面为示例
$ set -- 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
$ echo ${@:7}
7 8 9 0 a b c d e f g h
$ echo ${@:7:0}
$ echo ${@:7:2}
7 8
$ echo ${@:7:-2}
bash: -2: substring expression < 0
$ echo ${@: -7:2}
b c
$ echo ${@:0}
./bash 1 2 3 4 5 6 7 8 9 0 a b c d e f g h
$ echo ${@:0:2}
./bash 1
$ echo ${@: -7:0}
Search for files in your home directory which have been modified in the last twenty-four hours. This command works this way because the time since each file was last modified is divided by 24 hours and any remainder is discarded. That means that to match -mtime 0, a file will have to have a modification in the past which is less than 24 hours ago.
Numeric arguments can be specified as +n for greater than n, -n for less than n, n for exactly n.