I am planning to connect to remote Linux hosts via SSH and call scripts with Windows PowerShell SSH.
As far as I understand, if the SSH connection is lost (timeout or connection reset) whilst the script is running on the remote Linux node, the script will terminate.
So far I have implemented the following sequence:
- Initiate a connection to the host via SSH
- Once connected, run the script
- Script replies with a unique lock file location i.e.
- PowerShell script polls for existence of the file
- When the script completes, the lock file is removed
- When PowerShell script cannot detect lock file, it then continues
A failure is considered when:
- If it cannot reconnect after a number of attempts, the operations fails.
- If the script on the remote host takes too long to run, then we abort the operation.
This is my first PowerShell script, so has anything like this been done before?
If not, does the above seem sensible and any other recommendations (would using screen be more sensible)?