[systemd-devel] Auto-start of a Service in systemd
Andrei Borzenkov
arvidjaar at gmail.com
Wed Oct 5 11:25:10 UTC 2016
On Wed, Oct 5, 2016 at 1:19 PM, Raghavendra. H. R <raghuhr84 at gmail.com> wrote:
> It's working fine now. We should give the default target of the system for
> WantedBy= of the Install section.
> So I used graphical.target in the Install section and it fixed my issue.
>
I doubt it was the reason. grpahical.target pulls in multi-user.target
unless you have very customized unit definitions.
> Thanks for the information.
>
>
>
> --
> Regards,
>
> Raghavendra. H. R
> (Raghu)
>
> On Wed, Oct 5, 2016 at 3:12 PM, Raghavendra. H. R <raghuhr84 at gmail.com>
> wrote:
>>
>> I ran "systemctl enable test.service" but when I restart it shows only
>> that the service is only enabled but not active and running.
>>
>> Here is the status of test.service
>>
>> ? test.service - Hey Bings
>> Loaded: loaded (/lib/systemd/system/test.service; enabled)
>> Active: inactive (dead)
>>
>>
>> For WantedBy= which attribute should be given, whether it is
>> "default.target" or the default target of the system ?
>> Running systemctl get-default shows graphical.target as the default
>> target.
>>
>> --
>> Regards,
>>
>> Raghavendra. H. R
>> (Raghu)
>>
>> On Wed, Oct 5, 2016 at 2:59 PM, Andrei Borzenkov <arvidjaar at gmail.com>
>> wrote:
>>>
>>> On Wed, Oct 5, 2016 at 12:23 PM, Raghavendra. H. R <raghuhr84 at gmail.com>
>>> wrote:
>>> > Hi All,
>>> >
>>> > I'm a newbie in Systemd init system and I'm trying to auto boot/start
>>> > my
>>> > service in systemd. But my service gets only enabled and it never runs
>>> > automatically.
>>> >
>>> > I modifying my unit file to depend on sysinit.target and
>>> > multi-user.target
>>> > by making use of I used After= this also didnt help.
>>> >
>>> > I would like to do something in my unit file from which systemd starts
>>> > my
>>> > service automatically after starting it's own system related services.
>>> >
>>>
>>> There is no such thing as "own systemd services". All services are
>>> equal (but some are more equal than others :)
>>>
>>> > Can anyone help me regarding this ?
>>> >
>>> >
>>> > My sample service
>>> > =============
>>> > [Unit]
>>> > Description=Hey Bings
>>> >
>>> > [Service]
>>> > ExecStart="Run an executable"
>>> >
>>> > [Install]
>>> > WantedBy=multi-user.target or sysinit.target
>>> >
>>>
>>> sysinit.target is wrong, it should never be used for normal service.
>>> multi-user.target should work as long as it is your default target (or
>>> dependency of default target).
>>>
>>> You did run "systemctl enable your.service", did not you? What
>>> "systemctl status your.service" says?
>>
>>
>
More information about the systemd-devel
mailing list