Hm, that looks most likely to be caused by an issue on the server. A stale NFS handle occurs when the client is holding a reference to something that's whisked away from under it by another client. The most common cause is when a client changes into a working directory which is then deleted - when the client then tries to access something relative to its current directory (including .
and ..
) then it gets the stale handle error. In this case the "client" is in fact part of the environment that's running your script, so this isn't related directly to some issue in your code.
I suspect it's most likely that your script was kicked off just as some sort of server maintenance was going on which caused this issue, but the devs can probably shed more light on probable causes. My advice to try and minimise the problem is to always work with absolute path names, never relative to the current directory (i.e. all path names should start with /home/Johz
for files inside your home directory). Without knowing the exact cause I don't know how much this will help, but it's generally good practice anyway. To resolve a relative path name (e.g. ./mydir/file.txt
) the current working directory must be accessed, and if the current directory has become stale at any point since the script was started then this will fail. Absolute path names, however, involve following the path from /
(always accessible) down to the directory each time it's accessed. So, if the directory were to briefly disappear and reappear under the same name (but a different underlying object), an absolute access wouldn't be affected but a relative access would become stale. I probably haven't explained that very well, but I did my best. I managed to avoid using the term inode, at least. Damn, I was doing so well... (^_^)
Aside from that, occasional glitches are just a hazard of running 24/7 on a managed service which must periodically undergo maintenance and repair - as long as you write your script to be tolerant of failures at any point (i.e. don't leave anything lying around which will prevent it running next time) then it shouldn't be more than a minor annoyance unless it happens frequently.
You can read this page for a little more background on the error if you're interested, but it's not going to be of any actual help because it's aimed at operators/admins.