-1

When I connect via ssh to a terminal at work I need to keep sessions alive to run various scripts. However, I often find that the scripts fail because some directory ceases to exist in the meantime.

For example, I get errors like sh: 0: getcwd() failed: No such file or directory after a few hours, or The folder you are executing pip from can no longer be found if I run pip.

How do I go about solving this issue?

Ziofil
  • 99
  • 2
  • If you think tmux is responsible check your `~/.tmux.conf` to see if it is setting up some unusual config. In your shell `echo $PWD` should show the name of the current directory, even if it no longer exists. Perhaps the name of this dir may provide a clue. – meuh Apr 30 '19 at 15:48
  • why the downvote? – Ziofil May 06 '19 at 12:13
  • Indeed why the downvote. This happens very regularly to me with tmux if I quit X and restart. But the directory the tmux hosted shell is in is still there, – RichieHH Mar 13 '21 at 06:54

1 Answers1

2

Easy solution: Stay out of volatile directories

Better solution: Built good error handling in your scripts. Plenty of if [ -d "$DIRECTORY" ]; then blocks etc.

Sven
  • 97,248
  • 13
  • 177
  • 225
  • 1
    I simply log into my account and launch python scripts from my home directory. It looks as if it's due to tmux, because the errors never occur when I run scripts while logged via ssh. But I don't know how to debug it. – Ziofil Apr 30 '19 at 08:11