使用springboot内置tomcat部署项目到服务器,一段时间后文件上传不了

      SpringBoot项目使用内嵌tomcat jar包方式部署,一段时间后上传文件出现问题,上传不了,查看服务器日志发现是tomcat生成的临时目录tmp不存在,被linux系统机制自动清除了。

最简单的临时解决方案:重新启动项目,如果想要一劳永逸可以采用下面的方案。

方案1> 修改springboot的配置文件
配置参数 server.tomcat.basedir 不在tmp下创建目录。

方案2>修改清理 /tmp 下面的文件的机制
在/usr/lib/tmpfiles.d/tmp.conf/文件末尾追加 x /tmp/tomcat*


找到 usr/lib/tmpfiles.d 打开这个配置文件
[root@bogon tmpfiles.d]# cat 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
v /var/tmp 1777 root root 30d

# 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
Clear tmp directories separately, to make them easier to override
v /tmp 1777 root root 10d #清理tmp下十天没有发生变化的文件
Exclude namespace mountpoints created with PrivateTmp=yes
x /tmp/systemd-private-%b-*     #排除这个目录
X /tmp/systemd-private-%b-*/tmp   #排除这个目录,不排除这个目录包含的子目录/文件

文章参考:https://www.cnblogs.com/operationhome/p/12375003.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值