You are not logged in.
Hi
Systemd is a little confusing to me. I am trying to have a script executed during boot and so I have created this test script, "foo"
#!/bin/sh
touch foobar
in my home directory and made it executable. Then I have created the file .config/systemd/user/foo.service
[Unit]
Description=touch foobar
[Service]
Type=oneshot
ExecStart=/home/mojo/foo
WorkingDirectory=/home/mojo/
[Install]
WantedBy=multi-user.target
and then
$ systemctl --user enable foo
$ systemctl --user list-unit-files --type service | grep foo
foo.service enabled enabled
But the script is not executed on boot. What am I doing wrong?
Thanks,
Morten
Last edited by mortenbo (2021-11-06 11:10:18)
Offline
You installed your service into multi-user.target, but there is no such target for user sessions.
Look in /usr/lib/systemd/user; you'll probably want to install the service into default.target.
Offline
Welcome to the boards, please wrap outputs and text files in code tags
--user services need to have WantedBy on default.target , see https://wiki.archlinux.org/title/System … user_units
Offline
Also have a look at
"Automatic start-up of systemd user instances" https://wiki.archlinux.org/title/System … _instances
Offline
Bingo! Thanks to the both of you. I'll remember the code tags.
Offline