Files
linux-wiki/content/deepin折腾笔记/第五章/5.45.md
2021-10-21 14:57:58 +08:00

21 lines
919 B
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 5.45 创建服务延时执行命令
以下以创建一个执行1分钟后关闭错误报警蜂鸣声的服务为例用到了at定时执行需要提前安装
延时服务sudo apt install at
说明事实上延时执行是没有必要的仅以此为例用户可尝试修改ExecStart的脚本。
sudo dedit /etc/systemd/system/nobeep.service
Requires=atd.service
添加内容:
[Unit]
Description=Keep quiet when some error happens
Requires=atd.service
[Service]
Type=simple
ExecStart=/bin/bash -c "echo /sbin/rmmod pcspkr |at now + 1 minutes"
[Install]
WantedBy=multi-user.target
启用自定义服务并测试判断:
sudo systemctl enable nobeep.service
systemctl list-dependencies nobeep.service --reverse
sudo systemctl start nobeep.service
systemctl status nobeep.service