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?
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.
nano /usr/bin/script.sh
and Put the following line in it.
#!/bin/bash
ssh root@computerA '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.
Finally You need to add this line in your B.service file:
After=A.service
I hope my explanation was useful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.