Re: Creating a user-level systemd unit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



在 2021-06-29星期二的 12:42 +0100,Patrick O'Callaghan写道:
> I'm trying to get a specific service to start on login, and the usual
> method (KDE Autostart) isn't working so I'm trying to do it with a
> systemd unit:

How is that not working? Is it due to systemd-xdg-autostart-generator?
KDE on Wayland seems to be using systemd-xdg-autostart-generator by
default and causing some problems...

> 
>    $ cat startinsync.service 
>    [Unit]
>    Description=insync-headless service
>    After=default.target
>    
>    [Service]
>    ExecStart=/bin/sh /usr/bin/insync-headless start
Just an advice, If you have shebang ahead, you don't need /bin/sh.

ExecStart=/path/to/script.sh is enough, but make sure the script have
+x set.
>    KillSignal=SIGINT
>    
>    [Install]
>    WantedBy=default.target
> 
> The docs say that the place to put the unit file is given by:
> 
>    $ pkg-config systemd --variable=systemduserunitdir
>    /usr/lib/systemd/user

No, this place is usually for units installed by package manager.

Per-user unit files can be placed to 
 * ~/.config/systemd/user/ : for you only
 * /etc/systemd/user/ : for everyone on this system
You can check for the detail by `man SYSTEMD.UNIT 5`
>    
> So I copied the file there:
> 
>    $ ls -l /usr/lib/systemd/user/startinsync.service 
>    -rw-r--r--. 1 root root 177 Jun 29 12:31
> /usr/lib/systemd/user/startinsync.service

Execute `systemctl --user daemon-reload` to tell systemd instance that
files on disk have changed.
>    
> and tried to enable it:
> 
>    $ sudo systemctl enable startinsync
>    Failed to enable unit: Unit file startinsync.service does not
> exist.
That is for system units, to manage user units, use: 
 * systemd --user enable startinsync to enable for you only
 * systemd --global enable startinsync to enable for everyone on this
   system

>    
> I'm out of ideas.

Asking here is a great idea :)
> 
> poc
> _______________________________________________
> users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
> Fedora Code of Conduct: https://docs.fedoraproject.org/en-
> US/project/code-of-conduct/
> List Guidelines:
> https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives:
> https://lists.fedoraproject.org/archives/list/users@lists.fedoraproje
> ct.org
> Do not reply to spam on the list, report it:
> https://pagure.io/fedora-infrastructure

-- 
Qiyu Yan GPG keyid: 0x4FC914F065F2DF12 About:
https://fedoraproject.org/wiki/User:Yanqiyu

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux