0

I use disown to run long-running process via SSH. For example I run the following program:

vmd -e script.tcl > out.txt &

Then I use disown -a to deattach it from the shell. When I reconnect the terminal the out.txt shows that the program has finished. However, it shows the command prompt of the vmd (vmd>). VMD is a program for running TCL scripts for chemistry simulations. You can assume it is something like python with its own shell

http://www.ks.uiuc.edu/Training/Tutorials/vmd/tutorial-html/node8.html

After a while, I couldn't connect to ssh because of the limit on the running processes (fork retry: Resource temporary unavailable). First, I want to know how I can kill those disowned processes if they are in waiting state.

Second, I want to know if I exit the vmd program by putting exit at the end of my script.tcl, would it resolve the problem above for future uses?

migrated from serverfault.com Jun 10 '18 at 12:46

This question came from our site for system and network administrators.

  • vmd ain't a tool I ever heard about. Without some information about what that tool is, I don't think this question can be answered. – kasperd Jun 10 '18 at 11:08
  • 1
    These days, I would prefer to run this inside a screen or tmux session and not fiddle around with disown etc. – Sven Jun 10 '18 at 11:09
  • @kasperd I modified my question. – Ahmad Jun 10 '18 at 11:36
  • @Sven I can't run screen via SSH, the command is not found. I use MobaXTerm to connect the server. – Ahmad Jun 10 '18 at 11:37
  • @Ahmad Then just install it. – kasperd Jun 10 '18 at 11:40
1

There Is More Than One Way To Do It. (TM)

Solution 1 (probably the best): add the command to exit vmd to the end of your script.

Solution 2: redirect standard input of the vmd command to (or from, depending on your mindset) the null device, like so:

vmd -e script.tcl > out.txt < /dev/null &

That way when vmd is done with your script and tries to read the next command from standard input it will receive "end of file" and exit.

Solution 3: Kill the left over vmd process with kill. You'll need its PID for that which you can either note as the shell prints it after starting it with &, or find through the command ps ax. Try kill -TERM (the default) first, if that doesn't work use kill -HUP. Do not use kill -KILL aka kill -9.

Solution 4: Use screen or tmux instead of disown. That way you can reconnect to the running vmd process and enter further commands like exit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.