Run ClamAV as a Daemon

    1. LocalSocketGroup root
    2. User root

    Start the clamav-daemon

    1. systemctl start clamav-daemon
    • Test the software
    1. $ curl https://www.eicar.org/download/eicar.com.txt | clamdscan -
    1. stream: Eicar-Test-Signature FOUND

    For CentOS 7

    Run freshclam

    • Configure the freshclam to updating database
    1. cp /etc/freshclam.conf /etc/freshclam.conf.bak
    2. sed -i '/^Example/d' /etc/freshclam.conf
    • Create the init script
    1. cat > /usr/lib/systemd/system/clam-freshclam.service << 'EOF'
    2. # Run the freshclam as daemon
    3. [Unit]
    4. After = network.target
    5. [Service]
    6. Type = forking
    7. ExecStart = /usr/bin/freshclam -d -c 4
    8. Restart = on-failure
    9. [Install]
    10. WantedBy=multi-user.target
    11. EOF
    • Boot up
    1. systemctl enable clam-freshclam.service
    2. systemctl start clam-freshclam.service
    1. cp /usr/share/clamav/template/clamd.conf /etc/clamd.conf
    2. sed -i '/^Example/d' /etc/clamd.conf

    Run Clamd

    • Create the init script
    1. cat > /etc/init.d/clamd << 'EOF'
    2. case "$1" in
    3. start)
    4. /usr/sbin/clamd
    5. RETVAL=$?
    6. echo
    7. ;;
    8. stop)
    9. echo -n "Stopping Clam AntiVirus Daemon... "
    10. pkill clamd
    11. rm -f /var/run/clamav/clamd.sock
    12. rm -f /var/run/clamav/clamd.pid
    13. RETVAL=$?
    14. echo
    15. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamd
    16. ;;
    17. esac
    18. EOF
    1. chmod +x /etc/init.d/clamd
    • Boot up
    1. chkconfig clamd on
    2. service clamd start
    1. $ curl https://www.eicar.org/download/eicar.com.txt | clamdscan -