File system is full ..even though file is deleted

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat File system is full ..even though file is deleted
# 8  
Old 07-18-2013
Quote:
Originally Posted by Scrutinizer
But I think you cannot truncate a file that has been opened for writing.
You can:
Code:
$ cat truncate.c

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>

int main(void)
{
        int fd=open("filename.txt", O_CREAT|O_WRONLY);
        write(fd,"HEY GUYS ALJ AF MY FACE IS A ROTTORN BANANA", 43);
        ftruncate(fd, 0);
        close(fd);
}

$ gcc truncate.c
$ ./a.out
$ ls -l ./filename.txt

-rw-r-x--T 1 username users 0 Jul 18 11:04 filename.txt

$

I also tried sleeping while another process truncates, it succeeded too.
This User Gave Thanks to Corona688 For This Post:
# 9  
Old 07-18-2013
Smilie Yes, but that is by the same process and after it has finished writing to it. I mean truncate a file that is being written to by another process.

Last edited by Scrutinizer; 07-18-2013 at 02:32 PM..
# 10  
Old 07-18-2013
Quote:
Originally Posted by Scrutinizer
Smilie Yes, but that is by the same process and after it has finished writing to it. I mean truncate a file that is being written to by another process.
I knew you'd say that:

Quote:
Originally Posted by Corona688
I also tried sleeping while another process truncates, it succeeded too.
I've also truncated logfiles being written to. The results were the sparse file I mentioned.
# 11  
Old 07-18-2013
Yes, you are 100% right, it does create a sparse file. I must have not run du or not at the right moment in the past. I also normally truncate first but it did not always seem to have the desired effect in the past. I tested it now on both Red Hat Linux and Solaris 10 and although ls -l showed an ever growing file, it uses little actual space. It is also logical it happens this way..

On Solaris I sometimes seemed to have to truncate several times before it showed a lower disk usage. Might be a just a delay, maybe that is why it did not seem to work in the past.

When redirecting Bourne Shell on Solaris, there was no difference between writing and appending. In other shells the file became really 0 bytes in size when appending.. .

I do wonder if writing applications will never be bothered by such a file..

Anyway this is very good and useful information, and good insight.. thanks Smilie
This User Gave Thanks to Scrutinizer For This Post:
# 12  
Old 07-19-2013
thanks for all ur replies
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Root file system full..Need help

Hi guys, In sun E250 server,root file system is full. we cleared log files in var/adm folder syslogs,mail logs,crash logs are empty. This is a production server. we are not able to run fsck from single user mode. I have given output of df and du command.How to create space in root... (3 Replies)
Discussion started by: PUSHPARAJA
3 Replies

2. AIX

/tmp file system full

Hi, I would like to know if /tmp file system is full, wheather it will affect the peformance of application installed on AIX. if Memory and CPU are not heavily utilized. Regards, Manoj. (1 Reply)
Discussion started by: manoj.solaris
1 Replies

3. Red Hat

File system full, but not really.

Hey all, What do you think mostly happened in the following situation? I have a Red Hat 5.5 server. Someone, somehow, managed to get two .nfs000.... type files that totaled over a terabyte in size. I removed them and thought things were back to normal. Then I started getting complains from... (2 Replies)
Discussion started by: geelsu
2 Replies

4. UNIX for Advanced & Expert Users

/opt file system full !!!

Can anyone help me in cleaning /opt filesystem.. i have checked all the options and i have cleared all the logs and the total size of the files in /opt is shown as 1.8GB were as the size of /opt is 4.8GB but wen i run the command # df -h /opt it gives capacity 99% Please help... (17 Replies)
Discussion started by: kjamsheed
17 Replies

5. Solaris

file system full

hello Even though I am not out of inodes or of space, the /var/adm/messages shows messages: file system full I am doing now fcsk -m (400G) and I am still waiting to see the fragmentation results (should I add another option to df to have a faster output?) Do you have any other hints... (6 Replies)
Discussion started by: melanie_pfefer
6 Replies

6. Solaris

file system full

I am receving following Error message in /var/adm/messages "NOTICE: alloc: /: file system full" Disk space usage is as beklow: df -k $ Filesystem kbytes used avail capacity Mounted on /dev/md/dsk/d10 76678257 56962561 18948914 76% / /proc ... (8 Replies)
Discussion started by: Asteroid
8 Replies

7. Solaris

Full file system?

I read the sticky and thought of a script I use on a regular basis. Since unless you patch/upgrade the df command on solaris you have a very tought time teling how full the system truly is. Output looks like $ biggest.sh /tmp Filesystem kbytes used avail capacity Mounted... (0 Replies)
Discussion started by: meyerder
0 Replies

8. Solaris

File system full?

Hi, I just started working with UNIX on an old semi-fossilized Sun workstation which I use to process LOTS of images,however, I just started to get an error message that the file system is full and then my shell tool or/and text editor freeze up. Help? (8 Replies)
Discussion started by: Bend
8 Replies

9. UNIX for Advanced & Expert Users

Full File System

Hi All, There was a background process running on a Solaris 2.8 machine, and appeared to have filled all available disk-space. I done a killall, and upon re-booting found that the file system had filled up, and will not boot as normal as a result. For example, I'm getting /usr/adm/messages: No... (8 Replies)
Discussion started by: Breen
8 Replies

10. UNIX Desktop Questions & Answers

file system full

When I try to log in as root I get the following message realloccg /: file system full sendmail :NO Queue:low on space (have 0,SMTP-DAEMON needs 101 in /var/spool/mqueue) What should I do? (1 Reply)
Discussion started by: hopeless
1 Replies
Login or Register to Ask a Question