当 cronjob 触发时,logrotate 不会启动 proftpd

当 cronjob 触发时,logrotate 不会启动 proftpd

我目前没有想法了。如果 cron 任务触发 logrotate,proftpd 守护进程不会重新启动。 Logrotate 轮转所有日志文件,停止 proftpd,但不会再次启动 proftpd。

如果我强制旋转logrotate -f /etc/logrotate.d/proftpd-basic一切正常..

我得到了以下设置。

猫 /etc/cron.daily/logrotate

#!/bin/sh

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf 

猫 /etc/logrotate.conf

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0660 root utmp
    rotate 1
}

# system-specific logs may be configured here

猫 /etc/logrotate.d/proftpd-basic

/var/log/proftpd/proftpd.log
/var/log/proftpd/controls.log
{
        weekly
        missingok
        rotate 7
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                # reload could be not sufficient for all logs, a restart is safer
                invoke-rc.d proftpd restart 2>/dev/null >/dev/null || true
                #invoke-rc.d proftpd reload 2>/dev/null >/dev/null || true
        endscript
}

/var/log/proftpd/xferlog
/var/log/proftpd/xferreport
{
        monthly
        missingok
        rotate 7
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        prerotate
        endscript
        postrotate
                # reload could be not sufficient for all logs, a restart is safer
                invoke-rc.d proftpd restart 2>/dev/null >/dev/null || true
                #invoke-rc.d proftpd reload 2>/dev/null >/dev/null || true
                # run ftpstats on past transfer log
                ftpstats -a -r -l 2 -d -h -f /var/log/proftpd/xferlog.0 2>/dev/null >/var/log/proftpd/xferreport || true
        endscript
}

答案1

尝试在 invoke-rc.d 上使用绝对路径

/usr/sbin/invoke-rc.d

答案2

我曾经也有过一样的问题。看来是proftpd init脚本中的一个bug导致ftp服务器无法启动。看https://bugs.launchpad.net/ubuntu/+source/proftpd-dfsg/+bug/1246245

解决方法是更改​​配置以包含

     copytruncate

这将复制文件的内容,然后截断旧文件,而不是移动旧文件并创建新文件 - 这意味着您不需要重新启动守护程序。

相关内容