先把自己的 public key 送過去 (user charles-chang)。設定好 ssh 免 password.
準備 service file:
xeontitan:/etc/systemd/system# cat reportip.service [Unit] Description=send my ip address file to rdsuper Afteter=network-online.target [Service] User=charles-chang WorkingDirectory=/home/charles-chang ExecStart=/home/charles-chang/reportip.sh [Install] WantedBy=multi-user.targetcharles-chang 自己的 shell script:
cat /home/charles-chang/reportip.sh #!/bin/bash while true do ping -c 1 rdsuper if [ $? -eq 0 ] then break fi sleep 10 done ip addr > $HOSTNAME-ip scp $HOSTNAME-ip rdsuper:~/enable & start
systemctl daemon-reload systemctl enable reportip.service systemctl start reportip.service
沒有留言:
張貼留言