in my senario I have an linux service on computer that need to run after a service in computer B(computer A and B are in same network).how can I use system.d to do this job?
About linux : how-to-write-a-linux-service-to-start-a-service-on-computer-A-after-a-service-in-computer-B-is-up-and-runningcomputer-A-and-B-are-in-same-network
There are several solutions to this scenario, the simplest solution is to write a bash script like bellow.
before that you should set
ssh-key between 2 linux computer.
at first open a file.
and Put the following line in it.
#!/bin/bash ssh [email protected] 'systemctl start YOURServicName'
now you need to run this bash Script as SystemD Service in computer B.
[Unit] Description=My Shell Script [Service] ExecStart=/usr/bin/script.sh [Install] WantedBy=multi-user.target
for more info use this link.
You need to add this line in your B.service file:
I hope my explanation was useful.