Sharing Ilmu

Sharing for useful things

How To Management Temporary Files in Linux CentOS/RedHat

In this tutorial I’ll explain about how to management temporary files in linux centos/redhat. In this configuration usually used to remove files quickly from /tmp directory and can also remove files from another directory that are unused based on a certain time.

For do temporary files configuration is used systemd-tmpfiles and for this exercise we will try to remove specific /home/data directory that are unused during 30 second.

First create and configure file config in /etc/tmpfiles.d/

vim /etc/tmpfiles.d/tmp-data.conf

create configuration for directory /home/data exist, if not exist their will create automatically with permission 0700, group and user is root and will remove files on that directory in 30 sec.

if done, make sure the script that you create not have error and for clean for stale files in /home/data directory.

systemd-tmpfiles –clean /etc/tmpfiles.d/tmp-data.conf

 

And then,  run script systemd-tmpfiles –create for ensure the script in /etc/tmpfiles.d/tmp-data.conf have appropriate script and they will create the /home/data directory if not exist.

 

Create files on /home/data directory.

 

After you create file in /home/data directory, then sleep your system during 30 second.

sleep 30s

Running script systemd-tmpfiles and then check on /home/data directory for make sure the configuration successfull.

As the Shown image bellow, file on /home/data directory has been remove after 30 second.  The configuration successfully.

Let’s Try.

z

2 thoughts on “How To Management Temporary Files in Linux CentOS/RedHat

  • gadanija
    March 5, 2022 at 7:37 am

    Thanks for the marvelous posting! I definitely enjoyed reading it, you
    could be a great author. I will be sure to bookmark your blog and will eventually come
    back in the foreseeable future. I want to encourage you to definitely continue your great writing, have a nice evening!

  • more info here
    June 29, 2022 at 11:11 am

    bookmarked!!, I like your site!

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>