clamav on Ubuntu 18.04LTS

・インストール
sudo apt -y update
sudo apt upgrade
sudo reboot
sudo apt install clamav clamav-daemo

 

・アンインストール
sudo apt autoremove clamav
sudo apt autoremove clamav-daemon

 

・ウィルス定義ファイルの自動更新
systemctl start clamav-freshclam
systemctl enable  clamav-freshclam

 

・clamdscanを使うためのデーモン起動
systemctl start  clamav-daemon
systemctl enable  clamav-daemon

 

・手動でのclamdscan実行
clamdscan --multiscan download
以下のエラーが出る場合、ここを参考にsystemctrl restart clamav-daemon で再起動したりするとよい。
ERROR: Could not connect to clamd on LocalSocket /var/run/clamav/clamd.ctl:

 

スクリプトの作成
cat  clamdscan.sh

#!/bin/bash
mkdir -p /root/.clamtk/virus
mkdir -p /root/.clamtk/history

clamdscan /home/kazu \
  --infected \
  --multiscan \
  --fdpass \
  --move="/root/.clamtk/virus" \
  --log="/root/.clamtk/history/$(date +\%Y\%m\%d-\%H\%M\%S).log"

 

・除外したいパスを登録
root@hp-ub:~# head /etc/clamav/clamd.conf
ExcludePath ^/dev/
ExcludePath ^/proc/
ExcludePath ^/sys/
ExcludePath ^/root/.clamtk/
ExcludePath ^/mnt/

 

・crontabに登録
root@hp-ub:~# crontab -l
# Edit this file to introduce tasks to be run by cron.

# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task

# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.

# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).

# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/

# For more information see the manual pages of crontab(5) and cron(8)

# m h  dom mon dow   command
35 20 * * 5 /root/clamdscan.sh


multithreadを有効にしたclamdscanのほうがclamscanより数倍速い。