删除系统日志
查看系统日志所占空间
[user@localhost ~]$ sudo du --human-readable --max-depth=1 /var/log/
[user@localhost ~]$ sudo journalctl --disk-usage
What is:
[user@localhost ~]$ whatis du
du (1) - estimate file space usage
[user@localhost ~]$ whatis journalctl
journalctl (1) - Query the systemd journal
删除系统日志
sudo journalctl --vacuum-time=1weeks
journalctl
手册
--disk-usage
Shows the current disk usage of all journal files. This shows the
sum of the disk usage of all archived and active journal files.
--vacuum-size=, --vacuum-time=, --vacuum-files=
Removes the oldest archived journal files until the disk space they
use falls below the specified size (specified with the usual "K",
"M", "G" and "T" suffixes), or all archived journal files contain
no data older than the specified timespan (specified with the usual
"s", "m", "h", "days", "months", "weeks" and "years" suffixes), or
no more than the specified number of separate journal files remain.
Note that running --vacuum-size= has only an indirect effect on the
output shown by --disk-usage, as the latter includes active journal
files, while the vacuuming operation only operates on archived
journal files. Similarly, --vacuum-files= might not actually reduce
the number of journal files to below the specified number, as it
will not remove active journal files. --vacuum-size=,
--vacuum-time= and --vacuum-files= may be combined in a single
invocation to enforce any combination of a size, a time and a
number of files limit on the archived journal files. Specifying any
of these three parameters as zero is equivalent to not enforcing
the specific limit, and is thus redundant.
删除临时文件缓存
使用 tmpwatch
sudo dnf install tmpwatch
手册
DESCRIPTION
tmpwatch recursively removes files which haven't been accessed for a given time. Normally, it's used to clean up directories which are
used for temporary holding space such as /tmp.
...
By default, tmpwatch dates files by their atime (access time), ...
...
... m for minutes, h for hours, d for days. If no suffix
is specified, time is in hours.
删除最近 3 小时没有访问的临时文件
[user@localhost ~]$ sudo /usr/sbin/tmpwatch -afv 3h /tmp
[1] http://crx.xmspace.net/linux_tmp_del.html