应用:Linux服务器在没有音频输出和显示输出的情况下,利用蜂鸣器可以快速判断启动状况。
添加systemd服务:
# /etc/systemd/system/beep-up.service
[Unit]
Description=Beep after system start
DefaultDependencies=no
After=multi-user.target
[Service]
Type=oneshot
ExecStart=/usr/bin/beep -f 3000 -l 100 -n -f 3500 -l 100 -r 2
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/beep-down.service
[Unit]
Description=Beep before system shutdown
DefaultDependencies=no
Before=exit.target
[Service]
Type=oneshot
ExecStart=/usr/bin/beep -f 3000 -l 100 -r 2 -n -f 2000 -l 150
[Install]
WantedBy=reboot.target halt.target poweroff.target
最后启用 beep-up.service 和 beep-down.service
Author: Leisurelybear
Link: https://blog.lebear.top/2020/03/11/136/
Copyright: Copyright © 2019-2022 LeisurelyBear All rights reserved.