采用的步骤:
/home/user/bin/test.sh
代码: 全选
#!/bin/bash
date >> /home/user/test.log
/etc/systemd/system/custom.service:
代码: 全选
[Unit]
Description=Local system resume actions
After=sleep.target
[Service]
Type=simple
ExecStart=/home/user/bin/test.sh
[Install]
WantedBy=sleep.target
systemctl start custom.service,尝试启动,运行一次,成功。家目录下出现test.log,说明custom.service和test.sh没问题,能正确执行,journalctl -u custom.service中出现新的运行记录。
此时执行systemctl status custom.service 检查状态:
代码: 全选
● custom.service - Local system resume actions
Loaded: loaded (/etc/systemd/system/custom.service; enabled; vendor preset: enabled)
Active: inactive (dead)
但是,待机再恢复时,此服务没有运行。/home/user/下没出现test.log,journalctl -u custom.service中没出现新的运行记录。
尝试用不同的方法待机 (pm-suspend, xfce4-session-logout, systemctl start suspend.target)均无效。



请问哪里做错了?