vishnu Simbu
vishnu Simbu

Reputation: 43

command to clean tmp directory on my web server

I was getting write failed: No space left on device (28) in my websites. So I checked my tmp size using ssh and it was 100% full.

What command can I use through ssh to free up space in the tmp directory?

Upvotes: 1

Views: 7579

Answers (6)

user18099
user18099

Reputation: 663

Test this command. It shows the files?

(replace /tmp/ if this is not the folder you wanted to clean up)

find /tmp/ -mtime +6 -exec ls   {} \;

Edit your cron table:

$> crontab -e

Add a line:

* 6 * * * find /tmp/ -mtime +6 -exec rm -r   {} \;

To permanently delete all files (daily) in /tmp, that are a handfull of days old.

Upvotes: 1

Kalaiyarasan
Kalaiyarasan

Reputation: 13384

You can remove the file inside the tmp directory just go to the tmp directory

cd tmp/

and run the following command

rm -rf ./

It will delete all the directories inside that directory.

and

rm -rf *.*

It will delete all the files inside that directory.

Upvotes: 0

Ed Heal
Ed Heal

Reputation: 59997

To overcome your problem do what one of the posters has suggested.

But to avoid it in the future set up a cron job to tidy up periodically.

Look into using find system command to find old files that can be safely deleted (i.e. temporary files that will not be in use).

Upvotes: 0

Shiridish
Shiridish

Reputation: 4962

rm -rf tmp/

Recursively deletes the directory tmp, and all files in it, including subdirectories. And better be careful with this command!!

Upvotes: 0

Mihai Iorga
Mihai Iorga

Reputation: 39704

cd /tmp
rm -fr *

With PHP I don't know if you have permission to delete the files:

$files = glob('/tmp/*');
foreach($files as $file){
   if(is_file($file)){
       unlink($file);
   }
}

Upvotes: 1

apfelbox
apfelbox

Reputation: 2634

You just need to remove the files

rm -rf /path/to/tmp/*

You need to adjust /path/to/tmp with the path to your directory containing the temp files.

Warning: Please keep in mind, that all removed files are truly removed (= lost). So check all parameters first, before using this command.

Upvotes: 1

Related Questions