问题
1Filesystem Size Used Avail Use% Mounted on
2udev 468M 0 468M 0% /dev
3tmpfs 99M 9.2M 89M 10% /run
4/dev/vda1 25G 21G 2.9G 88% /
5tmpfs 491M 0 491M 0% /dev/shm
6tmpfs 5.0M 0 5.0M 0% /run/lock
7tmpfs 491M 0 491M 0% /sys/fs/cgroup
8tmpfs 99M 0 99M 0% /run/user/0
9overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/58e453251fb99188f75b5896f024207840afe33d1d3f4174cd04146eb6028474/merged
10overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/560dbbf69dffb630e73d71006130591f4be06764e7b2386f1e6eea92b32ba768/merged
11overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/fb8f4f64bff5a866f12e3843bc0725e60f73d35e7ba1ca49e67303fbf303d180/merged
12shm 64M 0 64M 0% /var/lib/docker/containers/f2b024b8bd8f1fdb769d49643389d5f3ba7dcc4d569801cc61f496cfd11b53f7/mounts/shm
13shm 64M 0 64M 0% /var/lib/docker/containers/3194b2825046696e4cb86b0ae8bafe8c08e344a18dd15c83ea5a5aebfeb9d6f1/mounts/shm
14shm 64M 0 64M 0% /var/lib/docker/containers/dca2671737c75bf38b977d82444c1ffbcb3f6f78434fc1fd86f42a85e0da2472/mounts/shm
15overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/b45741020ab88cebca80dad561977217a208d63db3dfe3f1bad202e8f5b406c7/merged
16shm 64M 0 64M 0% /var/lib/docker/containers/3573f8fd42cc3e4a431ba19e7c378ab280a6877d8fef3fba9472e914fd1130b4/mounts/shm
17overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/906ef33f87f41cb9083d96f586cd02fbdb03ccc2869524d9478facab6fac703a/merged
18shm 64M 0 64M 0% /var/lib/docker/containers/46fcbac86280594bdef6494520577cd9e2ff9c9aae607c15f6918c0fada7e6eb/mounts/shm
19overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/eada7a872310cb779a2e8ae50fef3a282c32469a5436f4f1932d1cdcd50a0942/merged
20shm 64M 0 64M 0% /var/lib/docker/containers/3da690aee1425bd6c1c709f3d04ba4726be80b8b82a817450fa59b47648f70a4/mounts/shm
21overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/3f110619cf54c75488e242472961e7cf106d0a934414345daadcbe46c4c94faf/merged
22overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/910c0af2d732e4da05503ad6481740736299f96ec248d868e033a357b4d41d70/merged
23shm 64M 0 64M 0% /var/lib/docker/containers/aae8f93bc9fc5a6e1a478a64fca800983a4ceb10c37d0b4f60d20954257de938/mounts/shm
24shm 64M 0 64M 0% /var/lib/docker/containers/fcaea0a3fe2a823b1e429337b9a036c1aee08cfe219b057245677a0097601855/mounts/shm
25overlay 25G 21G 2.9G 88% /var/lib/docker/overlay2/a8a4cdfddf30395e0b1a889c62c1405b3a99a90d4f22072415dae4873eceb552/merged
26shm 64M 0 64M 0% /var/lib/docker/containers/22b04e7051175956dd0506422ff7e51e24ec2c545eee7f54a9b0f6cc71e72827/mounts/shm
发现**/var/**空间占用过大
1du -m -d 1 /var/log
11 ./unattended-upgrades
22665 ./journal
31 ./dist-upgrade
41 ./apt
51 ./chrony
61 ./installer
71 ./sysstat
82730 .
发现 /var/log/journal 空间占用过大
1total 2.7G
2-rw-r-----+ 1 root systemd-journal 128M May 29 15:04 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c1d771-0006197aced9881c.journal
3-rw-r-----+ 1 root systemd-journal 112M May 30 07:32 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c3eaf0-000619925e034092.journal
4-rw-r-----+ 1 root systemd-journal 104M May 30 19:20 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c5b20f-000619a029f02871.journal
5-rw-r-----+ 1 root systemd-journal 128M May 31 21:21 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c76256-000619aa0ef786f6.journal
6-rw-r-----+ 1 root systemd-journal 128M Jun 2 02:42 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c9670b-000619bfdd4ddc3a.journal
7-rw-r-----+ 1 root systemd-journal 128M Jun 3 09:13 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004cb7bfb-000619d877bdea4d.journal
8-rw-r-----+ 1 root systemd-journal 128M Jun 4 15:18 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004cd91ad-000619f20a121813.journal
9-rw-r-----+ 1 root systemd-journal 128M Jun 5 21:26 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004cfa6a2-00061a0b4365dfcc.journal
10-rw-r-----+ 1 root systemd-journal 128M Jun 7 03:44 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d1b493-00061a24835280d7.journal
11-rw-r-----+ 1 root systemd-journal 128M Jun 8 09:55 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d3c33b-00061a3de9cc730d.journal
12-rw-r-----+ 1 root systemd-journal 128M Jun 9 15:44 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d5d18d-00061a57342d495e.journal
13-rw-r-----+ 1 root systemd-journal 128M Jun 10 21:49 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d7ddc4-00061a70329d1d99.journal
14-rw-r-----+ 1 root systemd-journal 128M Jun 12 04:34 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d9ebd4-00061a896a23b643.journal
15-rw-r-----+ 1 root systemd-journal 128M Jun 13 11:07 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004dbfbfc-00061aa3300bddd7.journal
16-rw-r-----+ 1 root systemd-journal 128M Jun 14 16:27 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004de0bf9-00061abccc685c6e.journal
17-rw-r-----+ 1 root systemd-journal 128M Jun 15 20:05 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004e01b2b-00061ad56476188a.journal
18-rw-r-----+ 1 root systemd-journal 128M Jun 16 23:14 system.journal
19-rw-r-----+ 1 root systemd-journal 8.0M Aug 18 2022 user-1000.journal
20-rw-r-----+ 1 root systemd-journal 32M May 29 15:04 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c1d772-0006197acee518de.journal
21-rw-r-----+ 1 root systemd-journal 24M May 30 07:32 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c3eaf5-000619925e539c71.journal
22-rw-r-----+ 1 root systemd-journal 16M May 30 19:20 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c5b211-000619a029f23992.journal
23-rw-r-----+ 1 root systemd-journal 32M May 31 21:21 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c76261-000619aa0f5016d4.journal
24-rw-r-----+ 1 root systemd-journal 32M Jun 2 02:42 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c9670d-000619bfdd500e1d.journal
25-rw-r-----+ 1 root systemd-journal 32M Jun 3 09:13 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004cb7bfe-000619d877c91347.journal
26-rw-r-----+ 1 root systemd-journal 32M Jun 4 15:18 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004cd91b2-000619f20a6945ed.journal
27-rw-r-----+ 1 root systemd-journal 32M Jun 5 21:26 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004cfa6a8-00061a0b43be24be.journal
28-rw-r-----+ 1 root systemd-journal 32M Jun 7 03:44 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d1b498-00061a2483b3073f.journal
29-rw-r-----+ 1 root systemd-journal 32M Jun 8 09:55 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d3c33c-00061a3de9dac56b.journal
30-rw-r-----+ 1 root systemd-journal 32M Jun 9 15:44 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d5d195-00061a5734895d79.journal
31-rw-r-----+ 1 root systemd-journal 32M Jun 10 21:49 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d7ddc6-00061a7032abdc50.journal
32-rw-r-----+ 1 root systemd-journal 32M Jun 12 04:34 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d9ebd6-00061a896a3064a5.journal
33-rw-r-----+ 1 root systemd-journal 32M Jun 13 11:07 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004dbfbfe-00061aa3301bb9bd.journal
34-rw-r-----+ 1 root systemd-journal 32M Jun 14 16:27 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004de0bfd-00061abccc72ad76.journal
35-rw-r-----+ 1 root systemd-journal 32M Jun 15 20:05 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004e01b2e-00061ad564833219.journal
36-rw-r-----+ 1 root systemd-journal 32M Jun 16 23:14 user-1001.journal
调整
保留最近n天日志
- 修改只保留最近的n天日志
1# 保留最近1天的日志
2journalctl --vacuum-time=3d
输出
1Vacuuming done, freed 0B of archived journals from /var/log/journal.
2Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c1d771-0006197aced9881c.journal (128.0M).
3Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c1d772-0006197acee518de.journal (32.0M).
4Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c3eaf0-000619925e034092.journal (112.0M).
5Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c3eaf5-000619925e539c71.journal (24.0M).
6Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c5b20f-000619a029f02871.journal (104.0M).
7Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c5b211-000619a029f23992.journal (16.0M).
8Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c76256-000619aa0ef786f6.journal (128.0M).
9Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c76261-000619aa0f5016d4.journal (32.0M).
10Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004c9670b-000619bfdd4ddc3a.journal (128.0M).
11Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004c9670d-000619bfdd500e1d.journal (32.0M).
12Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004cb7bfb-000619d877bdea4d.journal (128.0M).
13Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004cb7bfe-000619d877c91347.journal (32.0M).
14Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004cd91ad-000619f20a121813.journal (128.0M).
15Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004cd91b2-000619f20a6945ed.journal (32.0M).
16Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004cfa6a2-00061a0b4365dfcc.journal (128.0M).
17Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004cfa6a8-00061a0b43be24be.journal (32.0M).
18Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d1b493-00061a24835280d7.journal (128.0M).
19Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d1b498-00061a2483b3073f.journal (32.0M).
20Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d3c33b-00061a3de9cc730d.journal (128.0M).
21Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d3c33c-00061a3de9dac56b.journal (32.0M).
22Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d5d18d-00061a57342d495e.journal (128.0M).
23Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d5d195-00061a5734895d79.journal (32.0M).
24Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d7ddc4-00061a70329d1d99.journal (128.0M).
25Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d7ddc6-00061a7032abdc50.journal (32.0M).
26Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004d9ebd4-00061a896a23b643.journal (128.0M).
27Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004d9ebd6-00061a896a3064a5.journal (32.0M).
28Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004dbfbfc-00061aa3300bddd7.journal (128.0M).
29Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004dbfbfe-00061aa3301bb9bd.journal (32.0M).
30Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004de0bf9-00061abccc685c6e.journal (128.0M).
31Deleted archived journal /var/log/journal/20190507113001705830172066515487/user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004de0bfd-00061abccc72ad76.journal (32.0M).
32Vacuuming done, freed 2.2G of archived journals from /var/log/journal/20190507113001705830172066515487.
- 查看结果
1ls -l
输出
1total 329M
2-rw-r-----+ 1 root systemd-journal 128M Jun 15 20:05 system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004e01b2b-00061ad56476188a.journal
3-rw-r-----+ 1 root systemd-journal 128M Jun 16 23:15 system.journal
4-rw-r-----+ 1 root systemd-journal 8.0M Aug 18 2022 user-1000.journal
5-rw-r-----+ 1 root systemd-journal 32M Jun 15 20:05 user-1001@9d4884bf907e4de4b8d98f9c79c65d58-0000000004e01b2e-00061ad564833219.journal
6-rw-r-----+ 1 root systemd-journal 32M Jun 16 23:15 user-1001.journal
设置日志的大小
- 修改日志的大小
1journalctl --vacuum-size=100M
输出
1Vacuuming done, freed 0B of archived journals from /var/log/journal.
2Deleted archived journal /var/log/journal/20190507113001705830172066515487/system@a0479cdaa431475c9af2d5c5d226dbdb-0000000004e01b2b-00061ad56476188a.journal (128.0M).
3Vacuuming done, freed 128.0M of archived journals from /var/log/journal/20190507113001705830172066515487.
增加定时任务
- 增加cron表达式, 每天0点执行一次
10 0 * * * journalctl --vacuum-time=1d
评论