want file to regenerate after deletion


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting want file to regenerate after deletion
# 8  
Old 09-18-2009
Ah.. I think you misunderstand what is meant by "creating a link". What you should do is create a backup directory path someplace safe. Then in that directory, create a HARD link to the user's userChrome.css file. When the new profile is created, simply create a HARD link in the user profile to the backup path.
This is what Frank is saying.. Not a soft link (aka symbolic link).

Quick note: The filesystem only really know files by their inode. The entry in the directory structure actually contains a filename and inode number in the filesystem. (The OS uses a vnode constructed from an inode.) Each inode contain a reference count. As long as the reference count is > 0, the file data will exist. So if you create a hard link to a file (using an existing filesystem directory entry or inode with a non-zero reference count), you create entry (path) in the filesystem that is just as valid as any other filesystem path that points to that inode. The file (from an system perspective) will not be deleted until the last hard link to the inode is deleted. Deleted it from one path and it's not there. But it is if you use one of the other hard links.

If the data is trashed, you can't restore it unless you are willing to pay the back-up-a-copy-at-creation-time cost and associated restore-it-fast-automatically costs..

Note that symbolic links (aka soft links) create a directory entry that contain the path to another directory entry. It doesn't point to an inode. So, this won't help you keep the file from disappearing.

Last edited by jp2542a; 09-18-2009 at 11:48 AM.. Reason: clarification
# 9  
Old 09-18-2009
Quote:
Originally Posted by jp2542a
Ah.. I think you misunderstand what is meant by "creating a link". What you should do is create a backup directory path someplace safe. Then in that directory, create a HARD link to the user's userChrome.css file. When the new profile is created, simply create a HARD link in the user profile to the backup path.
This is what Frank is saying.. Not a soft link (aka symbolic link).
Neither of these measures will prevent the chrome file from being corrupted. It's nearly the same problem as my example, for which they were forced to create a daemon to keep restoring a file which got corrupted or deleted.

I'd be tempted to just script it in their xinitrc or whatever equivalent you have. Every time they login, destroy their profile and restore it from a tarball somewhere.
# 10  
Old 09-18-2009
In the original post, the problem description stated that a high level directory get's trashed and the chrome file is several levels lower. Hence, this should be an effective and low impact bandage for the symptoms. No extra staff or system resources (i.e. daemons, cpus, memory, etc) other than a few bytes in the backup directory.

The preferred solution would be to eliminate the source of the corruption of the higher level directory. But it may not be the best mission critical solution for the moment.
# 11  
Old 09-18-2009
I would still love to hear a solution, but what I came up with was a login script that checked if the file exists and if not it would create it. I guess a self fixing link is a non-existent entity in the UNIX world.
# 12  
Old 09-18-2009
Naive.
# 13  
Old 09-19-2009
Sometime you just have to bit your tongue, shake your head and walk away.. Smilie

And sometimes not .... Smilie
# 14  
Old 09-20-2009
"jp4245a" is 100% correct: "eliminate the source of the corruption of the higher level directory".

There are only so many "Band Aids" you can stick to a computer before it bleeds to death.
(Methyl Sep 2009)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File content deletion

Hi Everyone, There are certain files under a folder 'ABC' and the entries for these files are there in another file(fname) under a different folder 'XYZ'. I want to compare the folder contents(ABC) with the file(fname) contents and delete the mismatching / non-existing ones from the file,... (4 Replies)
Discussion started by: swasid
4 Replies

2. UNIX for Dummies Questions & Answers

How Do I Regenerate the Shadow file

I guess the earlier problem I had with changing user passwords and creating new users is related to the shadow file. Anytime I change something to /etc/passwd or shadow I get locked out. HOW DO I REGENERATE THIS FILE. (1 Reply)
Discussion started by: Waitstejo
1 Replies

3. Shell Programming and Scripting

Deletion of lines in a text file

Hi Everyone, Please help me with this. I have gone through many posts here but couldn't find what I wanted. I have a file with 79000+ lines and I want to delete lines in a pattern. I want to delete every 141st line in the file, starting from line 2000 till 50000. Please help guys. ... (8 Replies)
Discussion started by: max29583
8 Replies

4. Programming

How to watch for file creation/deletion?

How do I write a C program that will watch a directory for file creation/deletion? Maybe it would receive a signal when someone creates a file? thanks, Siegfried (5 Replies)
Discussion started by: siegfried
5 Replies

5. Shell Programming and Scripting

Prompting for file deletion?

I got help in another forum but now I need further help so I figured I'd ask here. I had to write a script to delete certain filenames of certain size. I got this far.. find . -size 110c -name "*testing*" -print | xargs -n 1 rm -i It finds the correct files, but the prompts to delete are all... (2 Replies)
Discussion started by: NycUnxer
2 Replies

6. UNIX for Dummies Questions & Answers

file deletion problem

I am using unix via telnet ssh and i have a problem I was testing the server. I made a directory. Transfered a file from an ftp to it. Opened the file with the vi text editor --This where my problem came..... I tried deleting the file using rm somefile.htm when is typed ls i noticed that... (2 Replies)
Discussion started by: shdwsclan
2 Replies

7. UNIX for Dummies Questions & Answers

large file deletion

OS: Solaris 8 I deleted a large file (around 13 Gigs) from my system. But the output of df -k remains the same. The capacity % is constant. However one strange thing is happening- My available space is decreasing, my used space in increasing (The opposite should happen). This is happening... (2 Replies)
Discussion started by: run_time_error
2 Replies

8. UNIX for Dummies Questions & Answers

Deletion of File in Unix

Hi there guys. I'm quite new in using unix and just recently experienced missing file problem. Someone accidentally or likely intentionally deleted one specific folders that contains important file. Now my question is, can any other user aside from root can do such action? Please help. ... (2 Replies)
Discussion started by: rhomel101
2 Replies

9. Shell Programming and Scripting

File deletion when server restarts

Hi, In a shell script I am makin use of 3 files f1,f2 and f3.txt. When the Unix server is restarted I want to delete all these 3 files if they are existing. ( I suppose I will have to use this command rm /thefilepath/f* but dont know in which script to use.) Anyone knows what can be... (6 Replies)
Discussion started by: k_oops9
6 Replies
Login or Register to Ask a Question