SSD’s , booting too fast and clamd service fails

a brief post to serve as a reminder to myself in future (and hopfully help out others too)

** Edited on 1st July 2017 , the edit is below the original post, which I have kept intact. I may later repost a fully integrated edit.**

I recently got a second user SSD for what was a great price ( from PCBitz) , so I took time out to reinstall ArchLinux  all went smoothly and eventually I was booting up to my chosen DE (desktop environment) Plasma-Desktop by KDE  and I was booting very quickly

systemd-bootime

which is of course one of the reasons for having a SSD

There was one issue however, one of my services clamd which I use to scan downloads in Firefox with fireclam and email in Thunderbird using clamdrib

ERROR: TCP: getaddrinfo failed: Address family for hostname not supported

leading me to start the service manually at which case it woud work perfectly, this led me to the conclusion that although launching after the network services clamd was completing prior to my router issuing an address to my PC.

(and yes I switched back to Tunderbird after many months of using Evolution.)

quick recap The issue was I was booting too quickly and clamd was starting before the PC had received an address from the router.

the solution , my friend Andy over at andrzejl.eu suggested using chronie to delay the start up of the clamd service , which made sense as follows
andys-clamd-solution

However me being me… looked elsewhere for a solution

systemd ( yes obligatory boo hiss from some quarters) has a delay timer function built in all you need to do is set up a timer value and call for a .timer file instead of a .service file , all it takes is a small change to the .service file and save it as a .timer instead

first thing was to disable the systemd service file

sudo systemctl disable clamd.service

then edit the .service file adding

[Timer]
OnBootSec=10

and as it is launching as a time , ther is no need for the instruction to launch after  the network service so comment out that line

#After=network.target

so that the service file looks like

service.timer

then save as

/usr/lib/systemd/system/clamd.timer

all that is then needed is to enable the timer service , using

sudo systemctl enable clamd.timer

and reboot , on all subequent boots the clamd service is sucessfull as it delays its start by a period of 10 seconds , long after the network has started.

I’m hoping this helps someone somewhere , and shoud it not , try Andy’s solution noted above.

Jase

 

EDIT: (Saturday 1st July 2017) troubleshooting addendum

Everything was working great , then I updated . not sure why but my solution presented started to fail to work.

inorder to get this solution working again I did the following

sudo systemctl disable clamd.timer

sudo mv /usr/lib/systemd/system/clamd.timer /etc/systemd/system/

cd /etc/systemd/system

sudo nano clamd.timer

change OnBootSec=10 to OnActiveSec=10 and uncomment the #After line

so that the .timer file looks like

clamd.timer2

Then enable the timer with

sudo systemctl enable clamd.timer

I wil leave this rather disjointed post as it is , as it may help troubleshoot an issue later on.

Jase