I have two computers (let's call them master and slave) connected via ethernet with static IP addressing.

What I want to achieve is to reboot slave whenever master is rebooted, and power it off whenever master is powered off.

Both systems are runinng Ubuntu Bionic with systemd.

So far I only concentrated on the rebooting. I created file /lib/systemd/system/restart-jetson.service with the following contents:

Description=Restart Jetson
Before=systemd-reboot.service  # also tried just reboot.service

ExecStart=/bin/su -c 'echo "nvidia" | /usr/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no nvidia@%H-jetson "sudo -S reboot"' robot


Then I enabled the service with systemctl enable restart-jetson.service and systemctl daemon-reload.

SSH is configured for passwordless login on slave.

If I restart the service from a running system, slave is rebooted. However, rebooting the master system does nothing to the slave. How should I configure this systemd unit correctly?

Other SO posts or tutorials seem like this method should work, but for this particular use-case it doesn't seem to do anything.

  • 2
    Is your question, “How do I run a program/script when my system goes down for reboot?”? – ctrl-alt-delor Apr 6 at 21:29
  • Okay, I'll clarify the quetsion. The fact is other commands can be run using services like this, but the problem is in this particular use-case nothing happens. – Martin Pecka Apr 6 at 22:14

Your Answer

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

Browse other questions tagged or ask your own question.