[systemd-devel] systemd --user fails to start a user service at the first time
Andrei Borzenkov
arvidjaar at gmail.com
Fri Oct 29 18:01:37 UTC 2021
On 29.10.2021 19:24, Han wrote:
> I have a follow-up question inline. Thanks.
>
> On Thu, Oct 28, 2021 at 10:47 PM Han <keepsimple at gmail.com> wrote:
>
>>
>> On Thu, Oct 28, 2021 at 10:25 PM Andrei Borzenkov <arvidjaar at gmail.com>
>> wrote:
>>
>>> On 29.10.2021 04:54, Han wrote:
>>>> Hi,
>>>>
>>>> I'm a newbie to systemd. I encountered a strange problem when using
>>>> systemd user
>>>> service in Debian 10 (hardware: Raspberry Pi 4), systemd version 241.
>>>>
>>>> I posted this question on stackoverflow but didn't get answers yet.
>>> Hence
>>>> trying to ask here. My apologies if this is too basic.
>>>>
>>>> 1. I created a new service unit file at here:
>>>> /home/pi/.config/systemd/user/foo.service
>>>>
>>>> its content looks like this:
>>>>
>>>> [Service]
>>>> ExecStart=/home/pi/test/foo
>>>> WorkingDirectory=/home/pi/test
>>>>
>>>>
>>>> 1. I tried to start this service, but it failed:
>>>>
>>>> $ systemctl --user start foo
>>>> Failed to start foo.service: Unit foo.se
>>>
>>> Does it work after
>>>
>>> systemctl --user daemon-reload
>>>
>>> ?
>>>
>>
>> Yes, it worked after `daemon-reload`. Thank you so much!
>>
>
>
> "daemon-reload" reloads all unit files in the system. It seems to me such
> a big remedy for starting a single service. Is this the expected workflow
> or a workaround?
>
Normally systemd should load new unit definition that is not yet present
in memory automatically on first reference. Daemon-reload is needed when
unit definition changed since it has been cached.
> Also I tried to add a 2nd service "foo2.service" in the same way, now I
> don't have to run "daemon-reload" and it can start. I'm wondering why.
>
That is expected behavior.
More information about the systemd-devel
mailing list