参考---->:
https://www.cnblogs.com/minseo/p/13557947.html
Ubuntu在启动以后过一段时间大概20分钟左右会自动休眠,在另外一台主机使用脚本检测80端口可以看到多久休眠
禁用休眠前查看状态
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target ● sleep.target - Sleep Loaded: loaded (/lib/systemd/system/sleep.target; static ; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
8月 24 18:00:40 hdy-desktop systemd[1]: Reached target Sleep. 8月 24 18:02:50 hdy-desktop systemd[1]: Stopped target Sleep. 8月 24 18:22:50 hdy-desktop systemd[1]: Reached target Sleep. 8月 25 08:37:14 hdy-desktop systemd[1]: Stopped target Sleep. 8月 25 08:57:15 hdy-desktop systemd[1]: Reached target Sleep. 8月 25 09:03:24 hdy-desktop systemd[1]: Stopped target Sleep. 8月 25 09:23:25 hdy-desktop systemd[1]: Reached target Sleep. 8月 25 09:29:05 hdy-desktop systemd[1]: Stopped target Sleep. ● suspend.target - Suspend Loaded: loaded (/lib/systemd/system/suspend.target; static ; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
8月 24 18:02:50 hdy-desktop systemd[1]: Reached target Suspend. 8月 24 18:02:50 hdy-desktop systemd[1]: Stopped target Suspend. 8月 25 08:37:14 hdy-desktop systemd[1]: Reached target Suspend. 8月 25 08:37:14 hdy-desktop systemd[1]: Stopped target Suspend. 8月 25 09:03:24 hdy-desktop systemd[1]: Reached target Suspend. 8月 25 09:03:24 hdy-desktop systemd[1]: Stopped target Suspend. 8月 25 09:29:05 hdy-desktop systemd[1]: Reached target Suspend. 8月 25 09:29:05 hdy-desktop systemd[1]: Stopped target Suspend. ● hibernate.target - Hibernate Loaded: loaded (/lib/systemd/system/hibernate.target; static ; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
● hybrid-sleep.target - Hybrid Suspend+Hibernate Loaded: loaded (/lib/systemd/system/hybrid-sleep.target; static ; vendor preset: enabled)
Active: inactive (dead)
Docs: man:systemd.special(7)
|
禁止休眠
1
2
3
4
5
|
root@hdy-desktop:~# systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target Created symlink /etc/systemd/system/sleep.target → /dev/ null .
Created symlink /etc/systemd/system/suspend.target → /dev/ null .
Created symlink /etc/systemd/system/hibernate.target → /dev/ null .
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/ null .
|
再次查看状态,变成masked了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
root@hdy-desktop:~# systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target ● sleep.target Loaded: masked (Reason: Unit sleep.target is masked.)
Active: inactive (dead)
8月 24 18:00:40 hdy-desktop systemd[1]: Reached target Sleep. 8月 24 18:02:50 hdy-desktop systemd[1]: Stopped target Sleep. 8月 24 18:22:50 hdy-desktop systemd[1]: Reached target Sleep. 8月 25 08:37:14 hdy-desktop systemd[1]: Stopped target Sleep. 8月 25 08:57:15 hdy-desktop systemd[1]: Reached target Sleep. 8月 25 09:03:24 hdy-desktop systemd[1]: Stopped target Sleep. 8月 25 09:23:25 hdy-desktop systemd[1]: Reached target Sleep. 8月 25 09:29:05 hdy-desktop systemd[1]: Stopped target Sleep. ● suspend.target Loaded: masked (Reason: Unit suspend.target is masked.)
Active: inactive (dead)
8月 24 18:02:50 hdy-desktop systemd[1]: Reached target Suspend. 8月 24 18:02:50 hdy-desktop systemd[1]: Stopped target Suspend. 8月 25 08:37:14 hdy-desktop systemd[1]: Reached target Suspend. 8月 25 08:37:14 hdy-desktop systemd[1]: Stopped target Suspend. 8月 25 09:03:24 hdy-desktop systemd[1]: Reached target Suspend. 8月 25 09:03:24 hdy-desktop systemd[1]: Stopped target Suspend. 8月 25 09:29:05 hdy-desktop systemd[1]: Reached target Suspend. 8月 25 09:29:05 hdy-desktop systemd[1]: Stopped target Suspend. ● hibernate.target Loaded: masked (Reason: Unit hibernate.target is masked.)
Active: inactive (dead)
● hybrid-sleep.target Loaded: masked (Reason: Unit hybrid-sleep.target is masked.)
Active: inactive (dead)
|
重启主机
1
|
reboot |
再次查看
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
root@hdy-desktop:~# systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target ● sleep.target Loaded: masked (Reason: Unit sleep.target is masked.)
Active: inactive (dead)
● suspend.target Loaded: masked (Reason: Unit suspend.target is masked.)
Active: inactive (dead)
● hibernate.target Loaded: masked (Reason: Unit hibernate.target is masked.)
Active: inactive (dead)
● hybrid-sleep.target Loaded: masked (Reason: Unit hybrid-sleep.target is masked.)
Active: inactive (dead)
|
主机不在休眠了
重新启动休眠
1
|
systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target |
注意:改禁止休眠命令Ubuntu和Centos通用