doubts reg inodes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting doubts reg inodes
# 1  
Old 12-19-2005
Question doubts reg inodes

Dear all,
We have a logfile which is written into by a background process running continuously. This logfile size keeps increasing rapidly. While trying to manipulate the file, we deleted the file from the directory. But the process kept on writing into the file and the directory space got filled up.
According to inode concept, the file is not completely removed until the last reference to the inode is gone.
My question is how to trace these inodes which exist even after the files get deleted but a process is working on it.
Please let me know if i am not clear.
# 2  
Old 12-19-2005
AFAIK you will have to stop the continuous process and restart it. Otherwise the disk will fill up.

Unless there is a lock on the file
Code:
> path/to/file

will truncate the file, even while the logger is writing to it. So I don't get what other manipulations you would need - maybe "tail -10000 >anotherfile " the last entries if you need them.
# 3  
Old 12-19-2005
inodes ? hmm is this file opened by the process. or are you only redirecting the output of the process to this file. Looking at your scenario, i bliv it is the process who opens this file for writing. if the process creates it, then deleting should stop adding to the log, unless your program handles creation of the file again, while logging. So if you want this to stop, then your logging should have a logic not to recreate a file if it doesnt find one.
second, if the logging fails, the process should also close the log file descriptor. which if left open may recreate the file and write. ( it depends mostly on ur process, how it handles this log file)

if you are simply redirecting the log to the file, one way to stop logging is chmod and chown of this log file so that there are no write permissions on this file. the process ll stop logging into it further (and probably may even crash Smilie )
# 4  
Old 12-21-2005
Thanks a lot

Thanks a lot. It was quite helpful. Actually we are killing the process now to handle the situation.
# 5  
Old 12-21-2005
chmod has no effect on a file descriptor that is already open. The code will keep writing to the file. This is because permissions checking occurs only when the process first tries to open the file.

Code:
/* filetest.c will this keep writing after a chmod on the file mid-way? */
#include <stdio.h>
#include <stdlib.h>

#define ck(x)if((x)==1){perror("error on file");exit(EXIT_FAILURE);}
int main()
{
	FILE *out=fopen("./myfile","w");
	char tmp[32]={0x0};
	int i=0;

	for(i=0;i<1000;i++) ck(fprintf(out,"%d\n",i));
	printf("We are pausing now... push <Enter> to continue.. ");    
	fgets(tmp,sizeof(tmp),stdin);
	system("chmod 000 ./myfile");
	for(i=0;i<1000;i++) ck(fprintf(out,"%d\n",i));
    ck(fclose(out));
    printf("exiting with no errors...\n");
    return 0;
}

output:
Quote:
kcsdev:/home/jmcnama> cc filetest.c
kcsdev:/home/jmcnama> a.out
We are pausing now... push <Enter> to continue..
exiting with no errors...
kcsdev:/home/jmcnama> ll ./myfile
---------- 1 jmcnama prog 7780 Dec 21 07:51 ./myfile
kcsdev:/home/jmcnama> wc -l myfile
wc: cannot open myfile
kcsdev:/home/jmcnama> chmod 777 myfile
kcsdev:/home/jmcnama> wc -l myfile
2000 myfile
kcsdev:/home/jmcnama>
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Maximum inodes

Hi, Is there a restriction in the number of inodes a particular directory can have in Solaris. If so how can we determine that. Regards (3 Replies)
Discussion started by: @bhi
3 Replies

2. UNIX for Advanced & Expert Users

Help with Inodes please

How can i trace Inode structure and modify it in UNIX kernel? We want to change the inode structure in the sense that we want to add a new field to the inode data structure. So we want to know how and where to trace inode (7 Replies)
Discussion started by: Group_Inode
7 Replies

3. Solaris

/var: out of inodes

Dear Forum, Please help me i have SUNW,Sun-Fire-V240 with sun solaris 8,if i check inode in /var like below: # df -F ufs -o i Filesystem iused ifree %iused Mounted on /dev/md/dsk/d0 62354 310638 17% / /dev/md/dsk/d3 372992 0 100% /var... (2 Replies)
Discussion started by: fredginting
2 Replies

4. Filesystems, Disks and Memory

inodes

Hi, sorry to have written in other language i think i could do that. I would to know A file system use inodes indexed allocation as a method of allocating space. In the inode blocks are 10 references to direct, 1 indirect reference to a single block, 1 block indirect reference to a reference to... (1 Reply)
Discussion started by: maryprin
1 Replies

5. Solaris

Increasing inodes

Hi , Can someone help me to increase "inode" in solaris 9? Thanks in advance, Gowtham (8 Replies)
Discussion started by: gowthamakanthan
8 Replies

6. Linux

Inodes

Any good sites, tutorials that explain Inodes clearly and completely ? (3 Replies)
Discussion started by: nitin09
3 Replies

7. UNIX for Dummies Questions & Answers

inodes

how is the location of inodes in the physical disk. are they sequential like: bootblock|superblock|inode1|inode2| ....| datablock1|datablock2|datablock3 or are they distributed among data blocks like: bootblock|superblock|inode1|datablock1|inode2|datablock2|datablock3|inode3 |datablock4 (3 Replies)
Discussion started by: gfhgfnhhn
3 Replies

8. Solaris

inodes

hi i need to find all the files that r linked to the current file as i need to delete the file as well as few of its links :confused: thnx in advance (1 Reply)
Discussion started by: livemyway
1 Replies

9. Solaris

inodes???

Does anyone know what command I can run to check how many inodes are in use on a specific filesystem. On Data General servers I used to run the df -k command to check the status of the inodes for all file system.s (1 Reply)
Discussion started by: soliberus
1 Replies

10. Filesystems, Disks and Memory

INodes...

Could someone please explain to me the concept of INodes? Colour me a DOS/MacOS junkie, but I don't quite understand. Is there any relation to clusters, or physical distro.? ty. (3 Replies)
Discussion started by: boris888
3 Replies
Login or Register to Ask a Question