LoginSignup
0
0

More than 3 years have passed since last update.

PrivateTmp に残ったファイルの処理

Last updated at Posted at 2021-03-02

systemd が作成する PrivateTmp に、ユーザがアップロードするファイルが大量に残っていてOSの容量を圧迫していたので、適当に消すスクリプトを作成。

/root/remove_files_in_php_fpm_private_tmp.sh

#!/bin/bash

PHP_FPM_PRIVATE_TEMP=$(find /tmp -type d -name "*php-fpm*")
PHP_FPM_PRIVATE_TEMP="${PHP_FPM_PRIVATE_TEMP}/tmp"
find "${PHP_FPM_PRIVATE_TEMP}" -type f -exec rm {} \;

exit 0

cron で適当に実行

# crontab -e
...(snip)...
# removing php-fpm private temp files (not a directory)
5 * * * * /root/remove_files_in_php_fpm_private_tmp.sh >/dev/null
...(snip)...

ちなみに、ディレクトリを消しちゃうと、アップロードができなくなる。
その場合は、php-fpm を再起動すると、PrivateTmp が再作成される。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0