当前位置:首页 > 服务器类 > Linux > 正文内容

Centos7清理/tmp文件夹

Codefans4年前 (2022-01-02)Linux1870

 Centos 6以及6以下的系统使用watchtmp + cron来实现定时清理临时文件的效果,这点在Centos 7发生了变化。


一.  系统自动清理


 在Centos 7下,系统使用systemd管理易变与临时文件,/tmp目录的清理规则主要取决于/usr/lib/tmpfiles.d/tmp.conf文件的设定,默认的配置内容为:



#  This file is part of systemd.

#

#  systemd is free software; you can redistribute it and/or modify it

#  under the terms of the GNU Lesser General Public License as published by

#  the Free Software Foundation; either version 2.1 of the License, or

#  (at your option) any later version.

 

# See tmpfiles.d(5) for details

 

# Clear tmp directories separately, to make them easier to override

v /tmp 1777 root root 10d           #   清理/tmp下10天前的目录和文件

v /var/tmp 1777 root root 30d       #   清理/var/tmp下30天前的目录和文件

 

# Exclude namespace mountpoints created with PrivateTmp=yes

x /tmp/systemd-private-%b-*

X /tmp/systemd-private-%b-*/tmp

x /var/tmp/systemd-private-%b-*

X /var/tmp/systemd-private-%b-*/tmp

可根据个人需求调整清理时间


二.  手动清理


    系统默认情况下每日清理一次tmp目录文件,原理就是使用了tmpwatch。


    首先进行安装:yum install -y tmpwatch


    安装成功后,执行清理任务:tmpwatch 24 /tmp/    #删除/tmp目录下超过24小时未使用的文件,最小为1小时。

扫描二维码推送至手机访问。

版权声明:本文由图慧网发布,如需转载请注明出处。

本文链接:http://www.tuh8.com/index.php?mod=mall&act=view&id=25

分享给朋友:

“Centos7清理/tmp文件夹” 的相关文章

docker中安装宝塔面板

docker中安装宝塔面板

我的电脑是win10,安装的virtualbox其上装的ubutun14,ubutun也安装了docker,今天我补充一个完整的操作流程。怎么在docker中安装宝塔面板?先打个岔,这些命令总是记不住,所以记录在本文中,以便将来查询:列出所有的容器 IDdocker ps&nbs...

ubuntu格式化硬盘

(1)查看硬盘sudo fdisk -lu或sudo blkid(2)格式化磁盘 sudo mkfs.ext4 /dev/sdb (3)将格式化后的磁盘 挂载在8t目录下sudo mount /dev/sdb  ~/8t(4)修改/etc/fstab 添加开机自动挂载s...

Docker容器里的centos、unbuntu无法使用 systemctl 命令的解决方案

据说在 Linux Docker中无法使用 systemd(systemctl) 相关命令的原因是 1号进程不是 init ,而是其他例如 /bin/bash ,所以导致缺少相关文件无法运行。(System has not been booted with systemd as init syste...

bitwarden实现及踩坑记录

bitwarden 搭建背景免费用户LastPass目前只能在一个设备上登陆,所以迁移到bitwarden。bitwarden是开源的跨平台密码管理软件。搭建后可以有全部功能具体流传步骤前置条件:安装dockerbitwarden只支持Https,所以VPS需要有域名、开放80 、443端口。由于使...

详解 docker save 与 docker export 的区别

详解 docker save 与 docker export 的区别

缘起docker save和docker export都能导出镜像包,咋看起来区别似乎不大。本文就针对这个问题,试图搞清楚docker save和docker export的功能是什么?适用于什么应用场景?本文的测试的Docker版本如下,不保证所有版本的docker都能重现本文的结果。&...

Jupyter hub解决了中文乱码问题,JupyterHub

问题在使用matplotlib绘图时,会出现中文变成方框的问题解决方法找到服务器上jupyter hub中字体存放的路径import matplotlib     print(matplotlib.matplotlib_fname())2. 登陆Ju...