On a Windows Server 2003 in VMWare a Debian mail server is running as a relay. The Windows server is regularly restarted also the Debian system.
Unfortunately the Debian system 'loses' repeatedly the permissions under VMWare for /var/log/clamav. So clamav-daemon and clamav-freshclam are unable to use the log files and are unable to rotate the logs files (add new). The error also occurs in vCenter Server. I used Debian Lenny and Debian Squeeze. For the moment I can solve this problem when I enter these commands in the terminal:
# chown -R amavis:amavis /var/log/clamav/*
# /etc/init.d/clamav-daemon restart
# /etc/init.d/clamav-freshclam restart
The error seems to occur when the system wants to rotate the log file.
The Debian-System executes the command independently.
In /etc/crontab I added a few lines. After the starts you the username which executes the command.
Everey day at 07:01 am, 07:03 am and 07:05 the system shall execute commands. Have a look at /var/log/syslog to proof it. I used 'mc' or 'nano' .
/etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
# Added commands so that clamav-freshclam and clamav-daemon can use the logfiles.
1 7 * * * root chown -R amavis:amavis /var/log/clamav/*
3 7 * * * root /etc/init.d/clamav-daemon restart
5 7 * * * root /etc/init.d/clamav-freshclam restart
The stars represent from left to right minute (0-59) hour (0-23) day (0-31) month (0-12) weekday (0-7)
Never write only 5 stars in a command!
Example
The computer reboots every day at 02:30 am. It ist not really required (it ist a linux), just an example.
'root' stands for the user who executes the command.
30 2 * * * root /sbin/shutdown -r now
Every day at 07:01 am
1 7 * * *
From monday to friday at 05:10 am
10 5 * * 1,2,3,4,5
or
10 5 * * 1-5
Every 30 minutes
*/30 * * * *
Every hour a quarter past up to a quarter to for every 10 minutes
15-45/10 * * * *