Firefox PHP

/tmp fills up?

Posted by DarkKlown 
/tmp fills up?
October 04, 2006 09:50AM

I've only been running phorum for a short time but i just noticed that tmp files that get created in /tmp sometimes dont get cleaned up. So I'm noticing alot of smallish files being created. Do i have something misconfigured or should i just write a small shell script to cleanup any files older than a few hours?
Re: /tmp fills up?
October 04, 2006 11:13AM
This is normal and it is perfectly safe for you to write a script that deletes old files. Deleting the tpl-* files is not neccessary. These hold the compiled versions of the template files. If you do delete them nonetheless, they will be rebuilt by Phorum, only some users might experience broken pages if you are deleting compiled templates the moment that you are deleting them, so it's better not do to so.

Maybe the script that I use for cleaning the cache is useful for you. Here it is:


export PATH

find $CACHE -depth -user $WWWUSER -mtime +2 \
    | grep -v rewrite_rules \
    | grep -v tpl- \
    > $TMP

for ENTRY in `cat $TMP`; do
    if [ -d $ENTRY ]; then
        rmdir --ignore-fail-on-non-empty $ENTRY
        rm $ENTRY

rm $TMP
The rewrite_rules file is kept intact for the Real Name module, which writes that file. If your system does not know the --ignore-fail-on-non-empty option for rmdir, you might have to lookup the correct flag for suppressing error output about directories not being empty. If no such flag is available (which I doubt), then you could also use something like this:
    rmdir $ENTRY 2>&1 | cat > /dev/null

Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: /tmp fills up?
October 04, 2006 06:26PM
RedHat and Gentoo have a package called tmpwatch that can clean up your /tmp dir for you.

Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Re: /tmp fills up?
November 07, 2006 08:41AM
Sorry for my ignorance of bash syntax. Does this "TMP=$CACHE/clean.cache.files.$$"
-in the script above- has to be changed in some way to meet my own environment ? What "clean.cache.files" means ? It is important for me to correctly define which part of /tmp is cleaned beacause tmp dir is also used by other porgrams. Thanks for any help.
Re: /tmp fills up?
November 07, 2006 09:31AM
You do not have to modify that at all. It's just a temp file which is used to write a list of files to delete to. It says:
TMP=                  set variable $TMP
$CACHE                start with the value in the variable $CACHE
/clean.cache.files.   add the string "/clean.cache.files." to it
$$                    add the process id of the current process
So after running this, the variable $TMP might contain something like /your/cache/dir/clean.cache.files.12345.

Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: /tmp fills up?
November 08, 2006 12:13AM
Well I put:
WWWUSER=apache (who is the owner of the tmp files and dirs)

Then I saved the shell in a file that I named "" in phorum/scripts folder (perhaps it's not the best place but the easiest to remeber where it is)
and then I put it in my crontab so it could execute itshelf every hour

But this does not work and when I call the script directly like
I get this error
: bad interpreter: No such file or directory myforum/scripts/ /bin/sh
and when I look at /bin/sh it exists in its place

Any idea on what I'm doing wrong ?
Re: /tmp fills up?
November 08, 2006 09:18AM
Maybe you uploaded the file using binary FTP transfer to the server, adding an invisible character at the end of /bin/sh. I see no other explanation for this.

Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: /tmp fills up?
November 08, 2006 09:42AM
it could be that /bin/sh is simply not existing on your system.

Thomas Seifert
Phorum Development Team /
Custom Phorum and general software development
worry-free Phorum Hosting
Re: /tmp fills up?
November 08, 2006 06:47PM
to ts77: non, /bin/sh is present in its place;
to mmakaay: i uploaded the file as text file then run a chmod +x to make it executable, I also made a new file with the notepad to be sure no invalid characters are inside, but I still have : bad interpreter: No such file or directory myforum/scripts/ /bin/sh
Then I made a new file named test and placed it just under ther root "/" but nothing happens. I changed the --ignore-fail-on-non-empty to --verbose hoping to get some feedback from the machine, but everything is silent. This time I don't have the message above, but nothing happens not even a processing output. It is despairing.

Edited 1 time(s). Last edit at 11/09/2006 11:54PM by milos.
Re: /tmp fills up?
November 12, 2006 09:51PM
Hello Maurice,

I tried your script and modified the CASH variable as such:


Which is the link to all those extra directories created by SPAMHURDLE.

I loeade the script in my home directories, chod it to an executable 455 adn trid to call it via telnet.

I got these error messages :

/usr/home/yjulien/ cannot create /tmp/c9201e61e1a9a3d73c1d97db98ebb87
b/mod_spamhurdles/clean.cache.files.42477: permission denied
cat: /tmp/c9201e61e1a9a3d73c1d97db98ebb87b/mod_spamhurdles/clean.cache.files.424
77: No such file or directory
rm: /tmp/c9201e61e1a9a3d73c1d97db98ebb87b/mod_spamhurdles/clean.cache.files.4247
7: No such file or directory

Is it because the script tries to delete files while it is directories only?


Sorry, only registered users may post in this forum.

Click here to login