LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-12-2016, 07:20 PM   #1
ahc_fan
Member
 
Registered: Jan 2009
Location: Seattle, WA
Distribution: Slackware64 14.2
Posts: 259

Rep: Reputation: 11
How can I clean /tmp while system is running?


I know I can put a command in the shutdown script to clean /tmp, but I rarely reboot my computer. So how should I manage this? Do I use cron and periodically delete files that are certain age? Could someone provide examples? Thank you.
 
Old 03-13-2016, 11:28 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

Yes, a daily cron job should do the trick nicely. Possibly something like this:

Code:
find /tmp -xdev -type f -atime +1 -print | xargs rm
 
1 members found this post helpful.
Old 03-17-2016, 05:25 PM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Back when I ran Slackware (14'ish), I installed tmpwatch.
Seemed to do the job.

Now-a-days, I guess the new fangled thing is to mount /tmp as tmpfs file system and it gets
emptied on every reboot?
 
Old 03-17-2016, 09:30 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,636
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Not too familiar with tmpfs, but a Linux machine might well not be 'rebooted' for months at a time . . .
 
Old 03-18-2016, 12:59 AM   #5
kohli
LQ Newbie
 
Registered: Mar 2016
Posts: 5

Rep: Reputation: Disabled
The tmpreaper program can be used to clean up /tmp periodically. This program deletes everything that has not been accessed in a given timeframe, typically two weeks. For this to work properly, the filesystem it is on should have the atimes option enabled. If you use a tmpfs, which it appears you are doing, then you should be fine.

Of course, rebooting also clears /tmp, but that would be boring.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command to clean tmp at shutdown rng Slackware 43 08-02-2013 06:00 AM
"locked out of tmp folder" system appears to be running normally. poughkeepsie Red Hat 1 01-28-2010 02:09 PM
clean-tmp - cron task suse 10.3 flebber SUSE / openSUSE 2 10-07-2007 01:02 AM
How to clean /tmp mkhan919 Linux - Newbie 7 03-05-2007 01:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:54 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
Open Source Consulting | Domain Registration