TransWikia.com

How to run clamd by systemd as daemon on Centos 7

Server Fault Asked by vczm on November 18, 2021

# rpm -q centos-release
centos-release-7-5.1804.el7.centos.2.x86_64

# rpm -qa clam
clamav-filesystem-0.100.0-2.el7.noarch
clamav-data-0.100.0-2.el7.noarch
clamav-lib-0.100.0-2.el7.x86_64
clamav-update-0.100.0-2.el7.x86_64
clamav-server-systemd-0.100.0-2.el7.x86_64
clamav-devel-0.100.0-2.el7.x86_64
clamav-scanner-systemd-0.100.0-2.el7.x86_64
clamd-0.100.0-2.el7.x86_64
clamav-0.100.0-2.el7.x86_64

Below [email protected] as is.

# cat /usr/lib/systemd/system/[email protected]
[Unit]
Description = clamd scanner (%i) daemon
After = syslog.target nss-lookup.target network.target

[Service]
Type = forking
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/%i.conf
Restart = on-failure

I use the standard config with defaults settings

# /etc/clamd.d/mail.conf
LogSyslog yes
TCPSocket 3310
TCPAddr 127.0.0.1
User clamscan

start

After start no any errors

# systemctl start clamd@mail

09:02:35 -- clamd[3644]: Limits: Global size limit set to 104857600 bytes.
09:03:39 -- clamd[3664]: Received 0 file descriptor(s) from systemd.
09:03:39 -- clamd[3664]: clamd daemon 0.100.0 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)
09:03:39 -- clamd[3664]: Running as user clamscan (UID 992, GID 989)
09:03:39 -- clamd[3664]: Log file size limited to 1048576 bytes.
09:03:39 -- clamd[3664]: Reading databases from /var/lib/clamav
09:03:39 -- clamd[3664]: Not loading PUA signatures.
09:03:39 -- clamd[3664]: Bytecode: Security mode set to "TrustSigned".
09:04:01 -- clamd[3664]: Loaded 6575820 signatures.
09:04:08 -- clamd[3664]: TCP: Bound to [127.0.0.1]:3310
09:04:08 -- clamd[3664]: TCP: Setting connection queue length to 200

status

# systemctl status clamd@mail
● [email protected] - clamd scanner (rspamd) daemon
Loaded: loaded (/usr/lib/systemd/system/[email protected]; static; vendor preset: disabled)
Active: inactive (dead)

# lsof -i | grep 3310
Empty

Looks like the service was not run as daemon. I tried to edit the /usr/lib/systemd/system/[email protected], but got no expected result (it always restart)

[Service]
Type = simple
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/%i.conf --foreground=yes
Restart = on-failure

One Answer

The problem was in RAM. Used 512Mb, after increase it to 896Mb the problem was solved.

No need to use --foreground=all to run the service. This parameter also can be use in /etc/clamd.d/mail.conf

Answered by vczm on November 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP