SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
You might want to consider moving your code to /etc/rc.d/rc.local -- it runs last, so everything is mounted, daemons are going and all that sort of thing (that's where I do the /tmp clean out).
My desktop stays on for months in a row, so I run a simple script from cron.daily, deleting from /tmp all files that have not been accessed for a week.
If you clear /tmp in rc.local you remove these things that you create in rc.S
Code:
# Create /tmp/{.ICE-unix,.X11-unix} if they are not present:
if [ ! -e /tmp/.ICE-unix ]; then
mkdir -p /tmp/.ICE-unix
chmod 1777 /tmp/.ICE-unix
fi
if [ ! -e /tmp/.X11-unix ]; then
mkdir -p /tmp/.X11-unix
chmod 1777 /tmp/.X11-unix
fi
The double dash indicates rm that the rest of the arguments are positional and not options, should you have a file named "-i", for example. The first asterisk expands to the list of files and directories excluding the ones that are hidden. That's, I think, the point of the third dot-asterisk argument. However, that dangerously expands to include ".." too, so I'm not sure if I'd use it.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Oh, yeah, I should have noted that the way I do this (from /etc/rc.local is with the find utility:
Code:
find /tmp -mtime +1 -print -exec rm -r {} \;
The -print is not necessary (it prints the list of stuff it's going to blow away, the list winds up in a log);
the -mtime +1 only finds stuff older than 1 day (so you don't blow away anything created during start up).
/tmp doesn't get blown away because it was modified a few seconds ago by start up stuff.
You can bury this is a shell program if you want (keeping the "standard Slackware way" intact; i.e., the check for an existing, executable file named rc.blah (which are, those rc.blah file, after all else is said, just shell programs)).
Yeah you're right. I'm not sure the man page makes sense in that respect.
Shouldn't it be -atime rather than -mtime though? As the hidden files won't be modified by rc.local therefore won't be spared when your code cleans /tmp. But they will presumably be "accessed" by the rc.local script when it checks if they are present or not.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.