Operating System - HP-UX
1831482 Members
3414 Online
110025 Solutions
New Discussion

Re: Removing linked files

 

Removing linked files

I have a "D" series server running HP-UX 11.0. I have a couple files that are soft links (lrwxrwxrxw .... filename) to files that are no longer there. If I try to delete the file, it tells me the device is busy and the file is not removed. Anybody know how to delete these guys? It isn't hurting anything having them out there except for my pride! I thought I knew how to remove files:-) Little help..... thank you.
18 REPLIES 18
Stefan Farrelly
Honored Contributor

Re: Removing linked files


you need to identify who is using the file in order to delete it. do an fuser to identify the process and try to kill the process first, or just user fuser -fk to just kill off the process, then you can rm the link.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Kofi ARTHIABAH
Honored Contributor

Re: Removing linked files

Hmm.. you might want to check to make sure that the file is not in use with:
fuser -cu /path/to/filename

then follow this thread:
http://my1.itrc.hp.com/cm/QuestionAnswer/1,1150,0x9b567e990647d4118fee0090279cd0f9,00.html
nothing wrong with me that a few lines of code cannot fix!
John Palmer
Honored Contributor

Re: Removing linked files

Bill,

What is the precise error that you get? and what did the links used to point to?

If the soft link does not point anywhere then I can't see any reason why you can't rm it - it can't be in use because it's not a file.

Regards,
John

Re: Removing linked files

Kofi,

fuser -cu returned:
/filename.

Also, fuser -fk /filename returned:
/filename: stat: No such file or directory
fuser could not find or access file /filename
Andy Monks
Honored Contributor

Re: Removing linked files

What are the links pointing too?

it could be that they point to 'open and unlinked files'. Oracle creates a tmp file, open's it and then deletes it, but keeps it open. fuser etc can't see this. However, I've never seen Oracle have a sym link to the file.
Stefan Farrelly
Honored Contributor

Re: Removing linked files


I think Andy has the answer, ive seen the same thing with some wierd application. Its not going to be easy to rm this link without shutting down the application or logging off the user who has the file still open. If you shutdown your apps or log everyone off overnight for backup then write a cron job to try to rm the link every hour or so overnight and hopefully by morning its gone.
Im from Palmerston North, New Zealand, but somehow ended up in London...

Re: Removing linked files

Andy / John,

The links don't point to anything. Usually, when you "LL" filename you see the links pointing to some other file. Hmmm, not here. It just says:

lrwxrwxrwx 1 root root 20 date/time filename
not
lrwxrwxrwx 1 root root 20 date/time filename --> some-other-filename

There's no --> symbol pointing to the file it's linked to. Weird!!
Kofi ARTHIABAH
Honored Contributor

Re: Removing linked files

Bill:

is it possible that the alias for ll has been redefined? try the following:

ls -lF filename or
ls -lL filename?
nothing wrong with me that a few lines of code cannot fix!
Anthony deRito
Respected Contributor

Re: Removing linked files

Bill, try creating a bogus file that the link used to be linked to using the touch command. Now try removing the link. Next, remove the bogus file.

Tony
Andy Monks
Honored Contributor

Re: Removing linked files

You could try 'unlink ' it might work. It's raw and nasty :-)

You want to check the man page first so your aware of how nasty!

Also, might be worth running the attached program. It display open files that are unlinked. Obviously doesn't show there names, but you get the inode, filesystem and size of the file. Might help.

Re: Removing linked files

The plot thickens. I just rebooted the system into single user mode - - working with the assumption that some application has the files open.... Ready for this, the files that were once links are now directories! I'm current;y bringing the system to multiuser mode to see if they go back to links again.. do do do do, do do do do .... (twilight zone...)

I let you all know what happens:-)
Andy Monks
Honored Contributor

Re: Removing linked files

You could try 'unlink ' it might work. It's nice and nasty. Check the man page first.

Also, you could try the attached program. it shows open files that are unlinked. Obviously not the name, but you get the inode number, filesystem and size of the file. It might help.
Victor BERRIDGE
Honored Contributor

Re: Removing linked files

Have you tried to use cmd unlink ?
Andy Monks
Honored Contributor

Re: Removing linked files

Not sure my last post made it.

Try doing an 'unlink '. it might work, but check the man page first
Antoanetta Naghiu
Esteemed Contributor

Re: Removing linked files

Bill,
Take a look at PHCO_18676 patch description. Do you have it installed?
Andrew Maslin
Frequent Advisor

Re: Removing linked files

You could also try creating another link of the same name in the same directory using ln -f -s command. Documentation states that -f destroys current links and creates a new one. The -s option specifies a soft link instead of a hard one. ln -f -i -s will prompt before actually carrying out the command. Once it's linked to an existing file, you should be able to remove the link.
Paul Hite
Trusted Contributor

Re: Removing linked files

I have attached a c program called inspectsymlink.c. Please compile it by doing:
cc inspectsymlink.c -o inspectsymlink

It should compile with the bundled cc compiler or any other c or c++ compiler.

Then run it by doing:
./inspectsymlink /path/to/funky/symlink

And then post the results. The data it prints may help in understanding what is going on.

Re: Removing linked files

GOT IT!! It was an NFS mounted filesystem that the files were linked to. The remote system has been gone for a while now but the links remained. I deleted the file systems via SAM and the link files are gone. HA, take that mysterious files! Be gone with you!!