[clamav-users] On Access Scanning as a Service
Alan Stern
stern at rowland.harvard.edu
Mon Dec 16 15:19:33 UTC 2019
On Mon, 16 Dec 2019, Walker, Glen wrote:
> Hello fellow ClamAV users!
>
> I am trying to start clamonacc as a service and have created the following file: /etc/systemd/system/clamonacc.service:
>
> #############
> [Unit]
> Description=ClamAV On Access Scanner
> Requires=clamav-daemon.socket
> After=syslog.target network.target clamav-daemon.service
>
> [Service]
> Type=simple
> User=root
> ExecStart=/usr/local/bin/clamonacc -F --log=/var/log/clamav/clamonacc --move=/tmp/quarantine
>
> [Install]
> WantedBy=multi-user.target
> ##############
>
> I can start the service manually no problem ("systemctl start clamonacc") but when I enable it I get the following error on boot:
>
> ERROR: ClamClient: could not connect to remote clam daemon, Couldn't connect to server
> ERROR: Clamonacc: daemon is local, but the connection could not be established
>
> I suspect that the problem is that my clamonacc.service is trying to start before the clamav-daemon service/socket is properly up and running (which is why I am able to manually start it after the boot process has completed).
>
> Does anyone have an insight or is there a guide/example clamonacc.service file that I could use/follow?
See the description of Requires= in the systemd.unit man page. It
says:
Note that requirement dependencies do not influence the order
in which services are started or stopped. This has to be
configured independently with the After= or Before= options. If
a unit foo.service requires a unit bar.service as configured
with Requires= and no ordering is configured with After= or
Before=, then both units will be started simultaneously and
without any delay between them if foo.service is activated.
Often, it is a better choice to use Wants= instead of Requires=
in order to achieve a system that is more robust when dealing
with failing services.
So you may need to add clamav-daemon.socket explicitly to the After=
line in the unit file.
Alan Stern
More information about the clamav-users
mailing list