不允许休眠

1
$ systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

查看状态

1
$ systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target

允许休眠

1
$ systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

参考:

https://zhuanlan.zhihu.com/p/468870436

https://blog.csdn.net/weixin_44120025/article/details/123184263