A script needs to run a long command on remote hosts and survive your laptop disconnecting. How do you design it?
IntermediateScenarioKubernetes, Docker, SSH & fleet automation
Answer
Situation read → Long-running remote work tied to a local SSH session dies with the session.
What I'd do →
- Do not keep the work in the SSH session: start it as a systemd transient unit (
systemd-run --unit=reindex ...) or insidetmux/nohup, and poll status. - Better: run the orchestration from a CI job or a bastion, not a laptop.
- On AWS, SSM Run Command keeps running independent of your client and stores output.
Why → Remote work should not depend on the controller's network.
Interview tip → systemd-run is a neat, less-known answer.
More on Kubernetes, Docker, SSH & fleet automation
You need a report of every pod in the cluster with no CPU or memory limits. How do you write it?BeginnerYou are asked to write a small operator-like script that adds a label to every new namespace. How do you approach it?AdvancedYou need to restart all Deployments in a namespace that reference a rotated Secret. How?AdvancedYour CI runners keep running out of disk because of Docker images. Write a cleanup plan in Python.IntermediateYou need to run `df -h` on 300 Linux hosts and list any above 85%. Python or Ansible?BeginnerA Python script SSHes to hosts with `AutoAddPolicy`. Security says that is unacceptable. What do you change?Intermediate