This is the manual, unnecessary method, I have figured out the how to do it the better way, described below.
I have done one or two before, and both work fine. I describe the method I used on my Ubuntu server above and used the manual way on my Manjaro PC. So let’s do it that way:
- Create the directory for the override file:
The directory can be found in the error:
Editing "/etc/systemd/system/pkgfile-update.service.d/override.conf" canceled: temporary file is empty.
So the directory is /etc/systemd/system/pkgfile-update.service.d
, so let’s create it:
sudo mkdir /etc/systemd/system/pkgfile-update.service.d
- And let’s move to it:
cd /etc/systemd/system/pkgfile-update.service.d
- Now let’s create the
override.conf
file:
sudo touch override.conf
- Now edit the file.
Use any editor you wish, I’m using `nano``.
sudo nano override.conf
- Add the following text to the file:
[Unit]
After=network-online.target nss-lookup.target
-
Save, Ctrl+O → Y, and exit, Ctrl+X → Y.
I used nano as example, but use the editor you prefer.
-
Reload the SystemD configuration files:
sudo systemctl daemon-reload
- (Just for giggles, not strictly necessary.) Restart the service:
sudo systemctl restart pkgfile-update.service
reboot
you computer and check now.
Edit:
After learning how to do it this way, it sort of makes sense why it didn’t work the first time. It also makes this much easier. After some searching, I came across this page, where the last comment states:
For clarification, this is a really common error to run into. When you run systemd edit, everything is commented out INCLUDING THE SECTIONS. If a user isn’t paying attention, its easy to add a valid rule under a commented out section, which will result in this “semi misleading” error. It’s not that the temporary file is empty, the file doesn’t have any uncommented sections.
So, it turns out the [Sections]
must also be un-commented. So edit the .service
unit again:
sudo systemctl edit pkgfile-update.service
There is a line:
### Anything between here and the comment below will become the new contents of the file
…followed by a few blank lines, and then the line:
### Lines below this comment will be discarded
So it’s obvious, when you look at it with more than a passing glance as to why we got the above error. So, copy and paste the line beginning with After
from below that last line, to between those 2 lines mentioned above, and remove the comment at the start of the line. Also add the [Unit]
section heading above it, so the file now looks like this:
GNU nano 7.1 /etc/systemd/system/pkgfile-update.service.d/.#override.conf6cc0056fc45b7088
### Editing /etc/systemd/system/pkgfile-update.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file
[Unit]
After=network-online.target nss-lookup.target
### Lines below this comment will be discarded
### /usr/lib/systemd/system/pkgfile-update.service
# [Unit]
# Description=pkgfile database update
# RequiresMountsFor="/var/cache/pkgfile"
# After=network-online.target
# Wants=network-online.target
#
# [Service]
# Type=oneshot
# ExecStart=/usr/bin/pkgfile -u
# Nice=19
# StandardOutput=null
# StandardError=journal
# PrivateTmp=yes
# PrivateDevices=yes
# CapabilityBoundingSet=
# NoNewPrivileges=yes
When done save, Ctrl+O → Y, and exit, CtrlCtrl+XX.
When exited, the configuration must be updated. (Yeah, I checked to make sure. But it can’t do harm anyway.)
sudo systemctl daemon-reload
You can now check if it worked:
systemctl cat pkgfile-update.service
At the bottom of the output, it should state:
# /etc/systemd/system/pkgfile-update.service.d/override.conf
[Unit]
After=network-online.target nss-lookup.target
It should now be safe to either restart the service:
sudo systemctl restart pkgfile-update.service
…or reboot the PC. When done, check the status that everything’s in order:
$ systemctl status pkgfile-update.service
○ pkgfile-update.service - pkgfile database update
Loaded: loaded (/usr/lib/systemd/system/pkgfile-update.service; static)
Drop-In: /etc/systemd/system/pkgfile-update.service.d
└─override.conf
Active: inactive (dead) since Fri 2022-12-23 10:43:47 SAST; 30min ago
TriggeredBy: ● pkgfile-update.timer
Main PID: 16225 (code=exited, status=0/SUCCESS)
CPU: 106ms
Dec 23 10:43:46 Mirdarthos-PC systemd[1]: Starting pkgfile database update...
Dec 23 10:43:47 Mirdarthos-PC systemd[1]: pkgfile-update.service: Deactivated successfully.
Dec 23 10:43:47 Mirdarthos-PC systemd[1]: Finished pkgfile database update.
Note the Drop-In: /etc/systemd/system/pkgfile-update.service.d
section shows it’s being over-wridden.
Note:
I noticed pkgfile-update.service
is triggered by pkgfile-update.timer
, which has a target of WantedBy=multi-user.target
. And, according to this page that is:
Set up a non-graphical multi-user system.
Meaning, AFAIK, it’ll only happen during the startup process when logging in. So, it might not have a big, or any really, influence on your startup time.