Previous TOC Next

Technical document: Virus detection with Clam Antivirus
Appendix B - Freshclam startup and shutdown script
This is a simple startup and shutdown script for freshclam. It is an adapted version of the script found here.

#!/bin/sh

###########################################################################
# CONFIGURATION

# Most configuration options are found in the freshclam.conf file.
# For more info see:
# man freshclam.conf

# The user to run as
user=clamav

# The prefix freshclam was installed to
prefix=/usr/local/bin

# The location for pid file
piddir=/var/run/clamav

###########################################################################
# SCRIPT

case $1 in
start)
        echo "Starting freshclam"
        mkdir -p $piddir
        chown $user $piddir
        su -m $user -c "$prefix/freshclam -d"
        ;;
stop)
        echo "Stopping freshclam"
        [ -f $piddir/freshclam.pid ] && kill `cat $piddir/freshclam.pid`
        ;;
*)
        echo "usage: freshclam.sh { start | stop }" >&2
        ;;
esac

Previous: Appendix A - Clam Antivirus startup and shutdown script TOC Next: Appendix C - ClamSMTP startup and shutdown script