LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-20-2016, 03:41 AM   #1
scryptkiddy
LQ Newbie
 
Registered: Jan 2014
Posts: 20

Rep: Reputation: Disabled
Question systemd-tmpfiles --clean


I'm having difficulty understanding, even after reading the man pages about the systemd-tmpfiles cleanup portion of the service.
I basically want to delete all files that are in my /data/analyst directory when they are older than a certain amount of time (I haven't decided yet, but let's say 2 minutes).

Here is what I know:
I came across some good reading on the manpage for tmpfiles.d which said it would read conf files from /etc/tmpfiles.d /run/tmpfiles.d and /usr/lib/tmpfiles.d

So I figured I'd put a conf file in /etc/tmpfiles.d

Code:
#touch /etc/tmpfiles.d/new_tmpfile.conf
Based on the reading and the format I added this:
Code:
# vim /etc/tmpfiles.d/new_tmpfile.conf

D  /data/analyst - - - 2m
I waited for 2 minutes, nothing happened.
I used D because man page said that "D Create or empty a directory". I'm looking to empty a directory...

Anyway...what am I missing, and / or do I need to restart a service?

Thanks

SK

Last edited by scryptkiddy; 05-20-2016 at 03:43 AM.
 
Old 05-20-2016, 07:50 AM   #2
dab1414
Member
 
Registered: May 2011
Location: OK, USA
Distribution: Slackware 14.1_64
Posts: 70

Rep: Reputation: 50
Quote:
Originally Posted by scryptkiddy View Post
I basically want to delete all files that are in my /data/analyst directory when they are older than a certain amount of time (I haven't decided yet, but let's say 2 minutes).
So why not just write a cron job to do this for you.

This one delete files older than 5 days
Code:
find /data/analyst/ -mindepth 1 -mtime +5 -delete
This one delete files older than 2 minutes
Code:
find /data/analyst/ -mindepth 1 -mmin +2 -delete
Both of those will also check sub-directories, if you want to automatically delete empty directories you can also do
Code:
find /path/to -type d -empty -delete
So in terminal
Code:
crontab -e
then editor, where your command is one of the ones i listed above.
Code:
#min hour day month weekday command
*/1   *    *    *    *     <your command>
 
1 members found this post helpful.
Old 05-20-2016, 02:58 PM   #3
scryptkiddy
LQ Newbie
 
Registered: Jan 2014
Posts: 20

Original Poster
Rep: Reputation: Disabled
Hey dab,

That's an awesome and great cron solution for sure. But I was reading on the benefits of systemd timers, and the main benefits come from each job having its own systemd service.

Here is what I found in my reading up on them:

◾ Jobs can be easily started independently of their timers. This simplifies debugging.
◾ Each job can be configured to run in a specific environment (see the systemd.exec(5) man page).
◾ Jobs can be attached to cgroups.
◾ Jobs can be set up to depend on other systemd units.
◾ Jobs are logged in the systemd journal for easy debugging.

The problem is, I just don't know how to set it up. I can't find a clear procedure from start to finish with examples and explanations. I'd really like to dive into this since its something I've never used, and learn it so I can have another 'tool in the toolbox' for my UNIX skillset =)

Any ideas?

SK
 
Old 05-20-2016, 03:55 PM   #4
dab1414
Member
 
Registered: May 2011
Location: OK, USA
Distribution: Slackware 14.1_64
Posts: 70

Rep: Reputation: 50
Well I haven't used systemd in awhile, however lets try this post

Code:
grep -v '^#' /usr/lib/systemd/system/systemd-tmpfiles-clean.timer
Code:
grep -v '^#' /usr/lib/systemd/system/systemd-tmpfiles-clean.service
If I remember correctly it does the cleanup after boot and daily, and the first commands result should show that


EDIT: also if everything is set up right you should be able to do below to start the cleanup of tmpfiles
Code:
systemd-tmpfiles --clean

Last edited by dab1414; 05-20-2016 at 04:07 PM.
 
1 members found this post helpful.
Old 05-21-2016, 10:01 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Your problem is that systemd isn't quite ready for that.

The cron specification should work for you at this time. It is both simpler, and easier to control.
 
Old 05-23-2016, 09:06 PM   #6
scryptkiddy
LQ Newbie
 
Registered: Jan 2014
Posts: 20

Original Poster
Rep: Reputation: Disabled
Appreciate the feedback dab and jpollard, I'll look into it more. I do agree that cron would work. However, I'm trying to develop a new skill using systemd that Red Hat has implemented.
 
Old 05-23-2016, 11:03 PM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Quote:
Originally Posted by scryptkiddy View Post
Appreciate the feedback dab and jpollard, I'll look into it more. I do agree that cron would work. However, I'm trying to develop a new skill using systemd that Red Hat has implemented.
Right now it is designed to be the init system.

In theory, it can be a session manager and I think that is what they will turn it into...

When they successfully do that, it would be the program started instead of using the startup shell script, and will respawn various Gnome services if/when they die (control panels, window managers, the auto start scripts).

Personally, I think it a waste of time, memory and system resources (systemd right now takes almost 30MB just doing that) adding yet more instances is much bigger than a shortlived shell process that turns into the window manager.

Systemd right now can handle a laptop fairly well (a relatively simple startup), but I'm not yet convinced it can actually handle really large servers --- It still seems to have trouble mounting complex filesystems, getting things done properly with network startup, has forced daemon services to use non-standard coding for them to even work (each daemon has to tell systemd when it has really started... which wasn't necessary before, and cannot monitor standard daemons). It also still has trouble getting site specific startup procedures going (it gets tricky... and if you don't get it right it can randomly not work... or not shutdown properly).
 
1 members found this post helpful.
Old 05-25-2016, 02:04 PM   #8
scryptkiddy
LQ Newbie
 
Registered: Jan 2014
Posts: 20

Original Poster
Rep: Reputation: Disabled
Good points, I'll wait until possibly RH8 when the systemd is a bit more usable / stable for things like this. Thanks for the feedback, much appreciated.
 
Old 05-25-2016, 02:09 PM   #9
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,094

Rep: Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515
If you want to stay on the bleeding edge of the systemd tech then grab fedora or arch for your laptop/home system. Its fun to see where it is going and keeping up with all the changes which will eventually end up in the enterprise distros.
 
1 members found this post helpful.
Old 05-25-2016, 03:51 PM   #10
MadeInGermany
Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 255

Rep: Reputation: 101Reputation: 101
Talking

Don't wait too long! In RH8 systemd might be replaced by monsterd that consumes 500 megabytes RAM and has the desktop integrated.
Just kidding.
 
Old 05-25-2016, 04:39 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Quote:
Originally Posted by MadeInGermany View Post
Don't wait too long! In RH8 systemd might be replaced by monsterd that consumes 500 megabytes RAM and has the desktop integrated.
Just kidding.
What it will be is a single container - with systemd+gnome+utilities... and consume 2GB just to start.
 
Old 05-25-2016, 08:32 PM   #12
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,094

Rep: Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515Reputation: 1515
Coming Soon: RHEL 8.0 kernelD
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't access full journalctl from script via systemd service even though user is in systemd-journal group iwtbf Linux - Newbie 0 02-19-2016 03:44 PM
LXer: Why pro-systemd and anti-systemd people will never get along LXer Syndicated Linux News 0 05-16-2015 12:44 AM
LXer: The Story Behind ‘init’ and ‘systemd’: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linu LXer Syndicated Linux News 0 09-06-2014 02:33 AM
LXer: Is systemd as bad as boycott systemd is trying to make it? LXer Syndicated Linux News 0 09-03-2014 06:50 PM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 10:02 AM


All times are GMT -5. The time now is 11:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration