有没有什么好办法可以让系统在关机的时候执行特定的命令

最好是使用systemd的, 我这儿有一个方法, 抛砖引玉:

创建一个systemd service文件, 内容如下

[Unit]
Description=
Before=shutdown.target

[Service]
ExecStart=/bin/true
ExecStop=/path/to/cmd
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

然后 systemctl enable service就可以了.

昨天在 https://t.me/debianzn 里讨论了一番, 基本上总结出了几个方法:
一个使用传统的创建 /etc/rc0.d 和 /etc/rc6.d 下文件来实现在不同的运行级别下运行命令.
一个是使用systemd,写一个service文件使其关联到shutdown.target
还有一个就是上面的帖子里列的方法.

不过第二种方法我没有实验成功, 找机会再试试看.