文章目录
- 删除系统日志
- 查看系统日志所占空间
- 删除系统日志
- 删除临时文件缓存
删除系统日志
查看系统日志所占空间
[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-usageShows the current disk usage of all journal files. This shows thesum 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 theyuse falls below the specified size (specified with the usual "K","M", "G" and "T" suffixes), or all archived journal files containno data older than the specified timespan (specified with the usual"s", "m", "h", "days", "months", "weeks" and "years" suffixes), orno more than the specified number of separate journal files remain.Note that running --vacuum-size= has only an indirect effect on theoutput shown by --disk-usage, as the latter includes active journalfiles, while the vacuuming operation only operates on archivedjournal files. Similarly, --vacuum-files= might not actually reducethe number of journal files to below the specified number, as itwill not remove active journal files. --vacuum-size=,--vacuum-time= and --vacuum-files= may be combined in a singleinvocation to enforce any combination of a size, a time and anumber of files limit on the archived journal files. Specifying anyof these three parameters as zero is equivalent to not enforcingthe specific limit, and is thus redundant.
删除临时文件缓存
使用 tmpwatch
sudo dnf install tmpwatch
手册
DESCRIPTIONtmpwatch recursively removes files which haven't been accessed for a given time. Normally, it's used to clean up directories which areused 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 suffixis specified, time is in hours.
删除最近 3 小时没有访问的临时文件
[user@localhost ~]$ sudo /usr/sbin/tmpwatch -afv 3h /tmp
[1] http://crx.xmspace.net/linux_tmp_del.html