Can we timeout cd command

Hi All,

I want to know whether we can timeout the cd command in unix.
If we can how is it implemented?
Suppose cd command hangs can we timeout the command.
Please help

Usually it doesn't hang ie. something else is the problem, filesystem, disk? Maybe try fix the causing problem first.

Well if there is some problem can we timeout the cd command?

Iam getting this error:-
NFS getattr failed for server bsm1a: error 5 (RPC: Timed out)

Someone plese help

Ah, NFS problems.. Does a ls hang too? If not, use that one mabye to check if the share is still available.

Hi,
ls command is failing too.

We have a script which takes the backup of the database.
Doing cd to a directory is one of the steps.
The directories are not properlu mounted and hence cd command is failing.
I want to know is there a way where i can timeout the cd command?

Not by a parameter or something like that afaik. You could check with ps if there is a cd command for that user and script, get it's PID and kill it, after a timer of 10 seconds or whatever is ok for you. You could make that part of your script in the background.
But even if I get on your nerves, you might want to fix that NFS problem.
Isn't it a appropriate way in your using ssh/scp/rsync to get your backup?

We had similar problems which we could not solve even with support - that's one of the reasons I really don't like NFS, tbh.

Well I want to implement the check in the same script. Is there no way to time out the "cd" command?

You can. In an earlier post Zaxxon described one way to do it.

A process performing disk i/o cannot be interrupted until the i/o completes. By default this also applies to NFS mounted filesystems. You can use a "intr" option to make NFS operation interruptable. You can also use a "soft" option to make them time out on their own. These are described on the mount_nfs man page or whatever man page describes nfs mounts for your OS.