サービスを作成しましたが、非アクティブ(死)として表示されます。

サービスを作成しましたが、非アクティブ(死)として表示されます。

これは他のトピックに関する質問とは異なります。私のUbuntuでサービスを作成しようとしていますが、このサービスは非アクティブ(死)と表示され続けます。

私のオペレーティングシステム:

ここに画像の説明を入力してください。

私のサービス(/etc/systemd/system/resume.serviceから):

[Unit]
Description=Run commands after resume from suspend
After=suspend.target

[Service]
ExecStart=/bin/sh /usr/local/bin/resume.sh

[Install]
WantedBy=suspend.target

私のシェルスクリプト(/usr/local/bin/resume.shから):

#!/bin/sh

# Workaround for XFCE bug re black screen on resume from suspend:
# if a user is logged into an X session via xfce, run 'xrandr --auto' to restore default display.

for id in $(loginctl list-sessions --no-legend | awk '{ print $1 }')
do
    s="$(loginctl show-session "$id")"
    if printf "$s" | grep -q 'Display=:0'
    then
        if printf "$s" | grep -q 'Desktop=xfce'
        then
            u="$(printf "$s" | grep 'Name=' | cut -d'=' -f2)"
            DISPLAY=:0 su "$u" -c 'xrandr --auto'
            exit
        fi
    fi
done

頑張ったこのコマンドただし、サービスを有効にすることはできません。

sudo systemctl enable resume.service
sudo systemctl start resume.service

$sudo systemctl statusresume.serviceを実行した後:

○ resume.service - Run commands after resume from suspend
     Loaded: loaded (/etc/systemd/system/resume.service; enabled; vendor pres>
     Active: inactive (dead)

سپتامبر 15 22:59:00 linux systemd[1]: resume.service: Deactivated successfull>
سپتامبر 15 22:59:30 linux systemd[1]: Started Run commands after resume from >
سپتامبر 15 22:59:30 linux systemd[1]: resume.service: Deactivated successfull>
سپتامبر 15 23:00:57 linux systemd[1]: Started Run commands after resume from >
سپتامبر 15 23:00:57 linux systemd[1]: resume.service: Deactivated successfull>
سپتامبر 15 23:04:02 linux systemd[1]: Started Run commands after resume from >
سپتامبر 15 23:04:02 linux systemd[1]: resume.service: Deactivated successfull>
سپتامبر 15 23:10:36 linux systemd[1]: Starting Run commands after resume from>
سپتامبر 15 23:10:36 linux systemd[1]: resume.service: Deactivated successfull>
سپتامبر 15 23:10:36 linux systemd[1]: Started Run commands after resume from

ベストアンサー1

おすすめ記事