Starting clamav as systemd service fails

Mikael Johansson picture Mikael Johansson · Aug 31, 2017 · Viewed 7.8k times · Source

I have installed ClamAV in CentOS 7.3 and have problems when starting clamd as a systemd service.

When I start clamd manually from the command line (/usr/sbin/clamd -c /etc/clamd.conf), everything goes well and I can connect using clamdscan.

When I start clamd via systemd, (systemctl start clamd), clamd starts and, after a few seconds, terminates with the message 'Waiting for all threads to finish' in the log file.

Has anyone any idea why clamd starts OK from the command line but not as a service? Configuration and log files follows. Thank you.

/usr/lib/systemd/system/clamd.service:

[Unit]
Description = clamd scanner daemon
After = network.target

[Service]
ExecStart = /usr/sbin/clamd -c /etc/clamd.conf
PrivateTmp = true

[Install]
WantedBy=multi-user.target

/etc/clamd.conf:

LogFile /tmp/clamd.log
LogTime true
LogVerbose true
TCPSocket 3310
TCPAddr localhost

logfile:

Thu Aug 31 09:52:18 2017 -> +++ Started at Thu Aug 31 09:52:18 2017
Thu Aug 31 09:52:18 2017 -> Received 0 file descriptor(s) from systemd
Thu Aug 31 09:52:18 2017 -> clamd daemon 0.99.2 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)
Thu Aug 31 09:52:18 2017 -> Log file size limited to 1048576 bytes.
Thu Aug 31 09:52:18 2017 -> Reading databases from /var/lib/clamav
Thu Aug 31 09:52:18 2017 -> Not loading PUA signatures.
Thu Aug 31 09:52:18 2017 -> Bytecode: Security mode set to "TrustSigned".
Thu Aug 31 09:52:24 2017 -> Loaded 6303399 signatures.
Thu Aug 31 09:52:26 2017 -> TCP: Bound to [127.0.0.1]:3310
Thu Aug 31 09:52:26 2017 -> TCP: Stting connection queue length to 200
Thu Aug 31 09:52:26 2017 -> Limits: Global size limit set to 104857600 bytes.
Thu Aug 31 09:52:26 2017 -> Limits: File size limit set to 26214400 bytes.
Thu Aug 31 09:52:26 2017 -> Limits: Recursion level limit set to 16.
Thu Aug 31 09:52:26 2017 -> Limits: Files limit set to 10000.
Thu Aug 31 09:52:26 2017 -> Limits: Core-dump limit is 0.
Thu Aug 31 09:52:26 2017 -> Limits: MaxEmbeddedPE limit set to 10485760 bytes.
Thu Aug 31 09:52:26 2017 -> Limits: MaxHTMLNormalize limit set to 10485760 bytes.
Thu Aug 31 09:52:26 2017 -> Limits: MaxHTMLNoTags limit set to 2097152 bytes.
Thu Aug 31 09:52:26 2017 -> Limits: MaxScriptNormalize limit set to 5242880 bytes.
Thu Aug 31 09:52:26 2017 -> Limits: MaxZipTypeRcg limit set to 1048576 bytes.
Thu Aug 31 09:52:26 2017 -> Limits: MaxPartitions limit set to 50.
Thu Aug 31 09:52:26 2017 -> Limits: MaxIconsPE limit set to 100.
Thu Aug 31 09:52:26 2017 -> Limits: MaxRecHWP3 limit set to 16.
Thu Aug 31 09:52:26 2017 -> Limits: PCREMatchLimit limit set to 10000.
Thu Aug 31 09:52:26 2017 -> Limits: PCRERecMatchLimit set to 5000.
Thu Aug 31 09:52:26 2017 -> Limits: PCREMaxFileSize limit set to 26214400.
Thu Aug 31 09:52:26 2017 -> Archive support enabled.
Thu Aug 31 09:52:26 2017 -> Algorithmic detection enabled.
Thu Aug 31 09:52:26 2017 -> Portable Executable support enabled.
Thu Aug 31 09:52:26 2017 -> ELF support enabled.
Thu Aug 31 09:52:26 2017 -> Mail files support enabled.
Thu Aug 31 09:52:26 2017 -> OLE2 support enabled.
Thu Aug 31 09:52:26 2017 -> PDF support enabled.
Thu Aug 31 09:52:26 2017 -> SWF support enabled.
Thu Aug 31 09:52:26 2017 -> HTML support enabled.
Thu Aug 31 09:52:26 2017 -> XMLDOCS support enabled.
Thu Aug 31 09:52:26 2017 -> HWP3 support enabled.
Thu Aug 31 09:52:26 2017 -> Self checking every 600 seconds.
Thu Aug 31 09:52:26 2017 -> Listening daemon: PID: 5518
Thu Aug 31 09:52:26 2017 -> MaxQueue set to: 100
Thu Aug 31 09:52:28 2017 -> Waiting for all threads to finish.
Thu Aug 31 09:52:29 2017 -> Shutting down the main socket.
Thu Aug 31 09:52:29 2017 -> --- Stopped at Thu Aug 31 09:52:29 2017
Thu Aug 31 09:52:29 2017 -> Closing the main socket

systemctl status clamd

clamd.service - clamd scanner daemon
Loaded: loaded (/usr/lib/systemd/system/clamd.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Thu 2017-08-31 09:52:29 UTC; 42 min ago
Main PID: 5516 (code=exited, status=0/SUCCESS)

Aug 31 09:52:18 localhost.localdomain systemd[1]: Started clamd scanner daemon.
Aug 31 09:52:18 localhost.localdomain systemd[1]: Starting clamd scanner daemon ...

Answer

Mikael Johansson picture Mikael Johansson · Sep 1, 2017

I messed up at the installation and missed installing, among other things, the clamav-server-systemd package.

Works alright now.