Systemd unit not found after OS crash and hard reboot
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I'm running Linux Mint kernel version 4.15.0-42-generic, and have a user systemd service file at ~/.local/share/systemd/user/my.service
:
[Unit]
Description=My service
After=network.target
After=systemd-user-sessions.service
After=network-online.target
StartLimitBurst=5
StartLimitIntervalSec=30s
[Service]
ExecStart="/my/command"
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=5
PrivateTmp=true
Environment=DISPLAY=:0
[Install]
WantedBy=default.target
It was installed by placing that file, then running systemctl --user daemon-reload
and then systemctl --user enable my.service
.
It works great, except when the OS crashes and a hard reboot (power cycle) is initiated. Upon logging back in, the service is not running.
In fact, it is not even found.
First commands after rebooting prove that systemd has lost the service, even though the file still exists and hasn't changed:
matt@brego:~$ systemctl --user status my.service
Unit my.service could not be found.
matt@brego:~$ ls -la ~/.local/share/systemd/user
total 20
drwxr-xr-x 2 matt matt 4096 Oct 16 15:56 .
drwxr-xr-x 3 matt matt 4096 Sep 28 13:58 ..
-rw-r--r-- 1 matt matt 458 Oct 16 15:56 my.service
matt@brego:~$ loginctl list-sessions
SESSION UID USER SEAT TTY
c2 1000 matt seat0
1 sessions listed.
Running systemctl --user start my.service
or systemctl --user enable my.service
results in the same error: Unit my.service could not be found.
I have to run systemctl --user daemon-reload
and then I can enable the service. Every. Time. After. Hard. Reboots.
How can I force systemd to run the service after the user logs in after the system reboots and after a power cycle? And to not forget about the service?
Edits to address further questions
Outputs of various commands after a hard reboot running as the same user:
matt@brego:~$ cat /etc/pam.d/systemd-user
# This file is part of systemd.
#
# Used by systemd --user instances.
@include common-account
session required pam_selinux.so close
session required pam_selinux.so nottys open
session required pam_loginuid.so
session required pam_limits.so
@include common-session-noninteractive
session optional pam_systemd.so
matt@brego:~$ ps -U $UID -f | grep systemd
matt 1341 1 0 13:34 ? 00:00:00 /lib/systemd/systemd --user
matt 1384 1341 0 13:34 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
matt 6870 1913 0 14:12 pts/1 00:00:00 grep --color=auto systemd
matt@brego:~$ systemctl --user list-units --type=target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
default.target loaded active active Default
paths.target loaded active active Paths
sockets.target loaded active active Sockets
timers.target loaded active active Timers
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
5 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
matt@brego:~$ systemctl --user status default.target
● default.target - Default
Loaded: loaded (/usr/lib/systemd/user/default.target; static; vendor preset: enabled)
Active: active since Tue 2018-12-04 13:34:34 MST; 38min ago
Docs: man:systemd.special(7)
Dec 04 13:34:34 brego systemd[1341]: Reached target Default.
systemd
add a comment |
up vote
3
down vote
favorite
I'm running Linux Mint kernel version 4.15.0-42-generic, and have a user systemd service file at ~/.local/share/systemd/user/my.service
:
[Unit]
Description=My service
After=network.target
After=systemd-user-sessions.service
After=network-online.target
StartLimitBurst=5
StartLimitIntervalSec=30s
[Service]
ExecStart="/my/command"
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=5
PrivateTmp=true
Environment=DISPLAY=:0
[Install]
WantedBy=default.target
It was installed by placing that file, then running systemctl --user daemon-reload
and then systemctl --user enable my.service
.
It works great, except when the OS crashes and a hard reboot (power cycle) is initiated. Upon logging back in, the service is not running.
In fact, it is not even found.
First commands after rebooting prove that systemd has lost the service, even though the file still exists and hasn't changed:
matt@brego:~$ systemctl --user status my.service
Unit my.service could not be found.
matt@brego:~$ ls -la ~/.local/share/systemd/user
total 20
drwxr-xr-x 2 matt matt 4096 Oct 16 15:56 .
drwxr-xr-x 3 matt matt 4096 Sep 28 13:58 ..
-rw-r--r-- 1 matt matt 458 Oct 16 15:56 my.service
matt@brego:~$ loginctl list-sessions
SESSION UID USER SEAT TTY
c2 1000 matt seat0
1 sessions listed.
Running systemctl --user start my.service
or systemctl --user enable my.service
results in the same error: Unit my.service could not be found.
I have to run systemctl --user daemon-reload
and then I can enable the service. Every. Time. After. Hard. Reboots.
How can I force systemd to run the service after the user logs in after the system reboots and after a power cycle? And to not forget about the service?
Edits to address further questions
Outputs of various commands after a hard reboot running as the same user:
matt@brego:~$ cat /etc/pam.d/systemd-user
# This file is part of systemd.
#
# Used by systemd --user instances.
@include common-account
session required pam_selinux.so close
session required pam_selinux.so nottys open
session required pam_loginuid.so
session required pam_limits.so
@include common-session-noninteractive
session optional pam_systemd.so
matt@brego:~$ ps -U $UID -f | grep systemd
matt 1341 1 0 13:34 ? 00:00:00 /lib/systemd/systemd --user
matt 1384 1341 0 13:34 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
matt 6870 1913 0 14:12 pts/1 00:00:00 grep --color=auto systemd
matt@brego:~$ systemctl --user list-units --type=target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
default.target loaded active active Default
paths.target loaded active active Paths
sockets.target loaded active active Sockets
timers.target loaded active active Timers
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
5 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
matt@brego:~$ systemctl --user status default.target
● default.target - Default
Loaded: loaded (/usr/lib/systemd/user/default.target; static; vendor preset: enabled)
Active: active since Tue 2018-12-04 13:34:34 MST; 38min ago
Docs: man:systemd.special(7)
Dec 04 13:34:34 brego systemd[1341]: Reached target Default.
systemd
1
- Does a file, which loadspam_systemd.so
exist in/etc/pam.d/
- most likely namedsystemd-user
? - After a crash, and before executing any other command, what doesps -U $UID -f | grep systemd
return (executed as the regular user under which you're seeing those issues)? - What doessystemctl --user list-units --type=target
return? - What doessystemctl --user status default.target
return? - Can you reproduce this issue using another Linux distribution (e.g. Ubuntu 18.04 or Fedora 29)?
– Elias Probst
Dec 5 at 8:49
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm running Linux Mint kernel version 4.15.0-42-generic, and have a user systemd service file at ~/.local/share/systemd/user/my.service
:
[Unit]
Description=My service
After=network.target
After=systemd-user-sessions.service
After=network-online.target
StartLimitBurst=5
StartLimitIntervalSec=30s
[Service]
ExecStart="/my/command"
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=5
PrivateTmp=true
Environment=DISPLAY=:0
[Install]
WantedBy=default.target
It was installed by placing that file, then running systemctl --user daemon-reload
and then systemctl --user enable my.service
.
It works great, except when the OS crashes and a hard reboot (power cycle) is initiated. Upon logging back in, the service is not running.
In fact, it is not even found.
First commands after rebooting prove that systemd has lost the service, even though the file still exists and hasn't changed:
matt@brego:~$ systemctl --user status my.service
Unit my.service could not be found.
matt@brego:~$ ls -la ~/.local/share/systemd/user
total 20
drwxr-xr-x 2 matt matt 4096 Oct 16 15:56 .
drwxr-xr-x 3 matt matt 4096 Sep 28 13:58 ..
-rw-r--r-- 1 matt matt 458 Oct 16 15:56 my.service
matt@brego:~$ loginctl list-sessions
SESSION UID USER SEAT TTY
c2 1000 matt seat0
1 sessions listed.
Running systemctl --user start my.service
or systemctl --user enable my.service
results in the same error: Unit my.service could not be found.
I have to run systemctl --user daemon-reload
and then I can enable the service. Every. Time. After. Hard. Reboots.
How can I force systemd to run the service after the user logs in after the system reboots and after a power cycle? And to not forget about the service?
Edits to address further questions
Outputs of various commands after a hard reboot running as the same user:
matt@brego:~$ cat /etc/pam.d/systemd-user
# This file is part of systemd.
#
# Used by systemd --user instances.
@include common-account
session required pam_selinux.so close
session required pam_selinux.so nottys open
session required pam_loginuid.so
session required pam_limits.so
@include common-session-noninteractive
session optional pam_systemd.so
matt@brego:~$ ps -U $UID -f | grep systemd
matt 1341 1 0 13:34 ? 00:00:00 /lib/systemd/systemd --user
matt 1384 1341 0 13:34 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
matt 6870 1913 0 14:12 pts/1 00:00:00 grep --color=auto systemd
matt@brego:~$ systemctl --user list-units --type=target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
default.target loaded active active Default
paths.target loaded active active Paths
sockets.target loaded active active Sockets
timers.target loaded active active Timers
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
5 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
matt@brego:~$ systemctl --user status default.target
● default.target - Default
Loaded: loaded (/usr/lib/systemd/user/default.target; static; vendor preset: enabled)
Active: active since Tue 2018-12-04 13:34:34 MST; 38min ago
Docs: man:systemd.special(7)
Dec 04 13:34:34 brego systemd[1341]: Reached target Default.
systemd
I'm running Linux Mint kernel version 4.15.0-42-generic, and have a user systemd service file at ~/.local/share/systemd/user/my.service
:
[Unit]
Description=My service
After=network.target
After=systemd-user-sessions.service
After=network-online.target
StartLimitBurst=5
StartLimitIntervalSec=30s
[Service]
ExecStart="/my/command"
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=5
PrivateTmp=true
Environment=DISPLAY=:0
[Install]
WantedBy=default.target
It was installed by placing that file, then running systemctl --user daemon-reload
and then systemctl --user enable my.service
.
It works great, except when the OS crashes and a hard reboot (power cycle) is initiated. Upon logging back in, the service is not running.
In fact, it is not even found.
First commands after rebooting prove that systemd has lost the service, even though the file still exists and hasn't changed:
matt@brego:~$ systemctl --user status my.service
Unit my.service could not be found.
matt@brego:~$ ls -la ~/.local/share/systemd/user
total 20
drwxr-xr-x 2 matt matt 4096 Oct 16 15:56 .
drwxr-xr-x 3 matt matt 4096 Sep 28 13:58 ..
-rw-r--r-- 1 matt matt 458 Oct 16 15:56 my.service
matt@brego:~$ loginctl list-sessions
SESSION UID USER SEAT TTY
c2 1000 matt seat0
1 sessions listed.
Running systemctl --user start my.service
or systemctl --user enable my.service
results in the same error: Unit my.service could not be found.
I have to run systemctl --user daemon-reload
and then I can enable the service. Every. Time. After. Hard. Reboots.
How can I force systemd to run the service after the user logs in after the system reboots and after a power cycle? And to not forget about the service?
Edits to address further questions
Outputs of various commands after a hard reboot running as the same user:
matt@brego:~$ cat /etc/pam.d/systemd-user
# This file is part of systemd.
#
# Used by systemd --user instances.
@include common-account
session required pam_selinux.so close
session required pam_selinux.so nottys open
session required pam_loginuid.so
session required pam_limits.so
@include common-session-noninteractive
session optional pam_systemd.so
matt@brego:~$ ps -U $UID -f | grep systemd
matt 1341 1 0 13:34 ? 00:00:00 /lib/systemd/systemd --user
matt 1384 1341 0 13:34 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
matt 6870 1913 0 14:12 pts/1 00:00:00 grep --color=auto systemd
matt@brego:~$ systemctl --user list-units --type=target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
default.target loaded active active Default
paths.target loaded active active Paths
sockets.target loaded active active Sockets
timers.target loaded active active Timers
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
5 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
matt@brego:~$ systemctl --user status default.target
● default.target - Default
Loaded: loaded (/usr/lib/systemd/user/default.target; static; vendor preset: enabled)
Active: active since Tue 2018-12-04 13:34:34 MST; 38min ago
Docs: man:systemd.special(7)
Dec 04 13:34:34 brego systemd[1341]: Reached target Default.
systemd
systemd
edited Dec 4 at 21:15
asked Dec 4 at 20:45
Matt
433410
433410
1
- Does a file, which loadspam_systemd.so
exist in/etc/pam.d/
- most likely namedsystemd-user
? - After a crash, and before executing any other command, what doesps -U $UID -f | grep systemd
return (executed as the regular user under which you're seeing those issues)? - What doessystemctl --user list-units --type=target
return? - What doessystemctl --user status default.target
return? - Can you reproduce this issue using another Linux distribution (e.g. Ubuntu 18.04 or Fedora 29)?
– Elias Probst
Dec 5 at 8:49
add a comment |
1
- Does a file, which loadspam_systemd.so
exist in/etc/pam.d/
- most likely namedsystemd-user
? - After a crash, and before executing any other command, what doesps -U $UID -f | grep systemd
return (executed as the regular user under which you're seeing those issues)? - What doessystemctl --user list-units --type=target
return? - What doessystemctl --user status default.target
return? - Can you reproduce this issue using another Linux distribution (e.g. Ubuntu 18.04 or Fedora 29)?
– Elias Probst
Dec 5 at 8:49
1
1
- Does a file, which loads
pam_systemd.so
exist in /etc/pam.d/
- most likely named systemd-user
? - After a crash, and before executing any other command, what does ps -U $UID -f | grep systemd
return (executed as the regular user under which you're seeing those issues)? - What does systemctl --user list-units --type=target
return? - What does systemctl --user status default.target
return? - Can you reproduce this issue using another Linux distribution (e.g. Ubuntu 18.04 or Fedora 29)?– Elias Probst
Dec 5 at 8:49
- Does a file, which loads
pam_systemd.so
exist in /etc/pam.d/
- most likely named systemd-user
? - After a crash, and before executing any other command, what does ps -U $UID -f | grep systemd
return (executed as the regular user under which you're seeing those issues)? - What does systemctl --user list-units --type=target
return? - What does systemctl --user status default.target
return? - Can you reproduce this issue using another Linux distribution (e.g. Ubuntu 18.04 or Fedora 29)?– Elias Probst
Dec 5 at 8:49
add a comment |
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485995%2fsystemd-unit-not-found-after-os-crash-and-hard-reboot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485995%2fsystemd-unit-not-found-after-os-crash-and-hard-reboot%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
- Does a file, which loads
pam_systemd.so
exist in/etc/pam.d/
- most likely namedsystemd-user
? - After a crash, and before executing any other command, what doesps -U $UID -f | grep systemd
return (executed as the regular user under which you're seeing those issues)? - What doessystemctl --user list-units --type=target
return? - What doessystemctl --user status default.target
return? - Can you reproduce this issue using another Linux distribution (e.g. Ubuntu 18.04 or Fedora 29)?– Elias Probst
Dec 5 at 8:49