赞
踩
1.创建一个自定义的服务
sudo vi /etc/systemd/system/custom-shutdown.service
编辑
[Unit]
Description=Custom shutdown service
After=network.target[Service]
Type=simple
ExecStart=/bin/bash /path/to/your/script.sh[Install]
WantedBy=multi-user.target
重启
sudo systemctl daemon-reload
启动服务
sudo systemctl enable custom-shutdown.service
如果脚本里有sudo
sudo visudo
yourusername ALL=(ALL) NOPASSWD: /path/to/handle_power_button.sh
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。