7

I've got a VMware ESXi server that I connected to via SSH to run a process. (I was running "vmkfstools --punchzero myVirtualDrive.vmdk" to reclaim space on a virtual disk). The SSH client connection was disconnected when the process was only 70% complete (with several hours of estimated time remaining).

  1. Was the process terminated when the SSH client dropped its connection to the ESXi host?
  2. Is there any way to tell if the process is still running?
    I did a quick ps|grep to find it, but didn't see anything that looked like vmkfstools.

On most standard linux machines, I use "screen" to avoid SSH client disconnection issues, but since the ESXi shell is purposely a very stripped down environment, I just ran the command straight away.

Thoughts?

NumericOverflow
  • 899
  • 8
  • 17

2 Answers2

11

The command was killed when you disconnected.

What you can do to prevent this in the future is to run the command with nohup. This will run your command in the background, continuing even when your shell "hangs up".

What I usually do when I expect a command to run long:

  • I ssh to a Linux machine that runs 24/7
  • start screen
  • ssh to the ESXi host
  • start the command

This way I don't have to worry about disconnects, I can just detach screen and go home after work and reattach screen the next morning to check the status of the command.

Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
  • 2
    Thanks, that's what I was afraid of, but I've restarted using noup as you suggested. One more nugget for others, you can prefix with "nohup" and then put an ampersand "&" at the end to push it to the background too, like so: `nohup someCommand -arg1 -arg2 &` – NumericOverflow Jun 21 '16 at 20:27
  • 1
    This was exactly what I was looking for, thanks to both of you! Saved me a lot of extra work this weekend :) – copeland3300 Jul 13 '18 at 21:04
1

This was exactly what I was looking for, thanks all. I attempted to unmap unused block on LUNs which is vmfs 5 file system. I run this cmd esxcli storage vmfs unmap -l [LUN-NAME] I wonder that what will happen if I close remote SSH connection while this cmd process still running.

Yasin
  • 21
  • 1
  • 3