Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # this script and "currentIP.txt" must be in the same directory
- # run "(hostname -I) > currentIP.txt" in bash before running this script the first time
- ip_rightNow=$(hostname -I)
- ip_prev=$(cat currentIP.txt)
- if [[ "$ip_rightNow" != "$ip_prev" ]]; then
- echo $ip_rightNow > currentIP.txt
- scp currentIP.txt user@XXX.XXX.XXX.XXX:/path/to/directory
- fi
- # above depends on ssh key authentication (no passphrase on key)
- # can add this to crontab to run every Y minutes with:
- # */Y * * * * /path/to/updateIP.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement