Skip to content

Linux Bash shell script to help you do something when your Internet IP Address changed.

License

Notifications You must be signed in to change notification settings

uf1y/do-something-when-your-internet-ip-changed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

do-something-when-your-internet-ip-changed

Linux Bash shell script to help you do something when your Internet IP Address changed.

How to use this script

chmod +x ipwatch.sh
# For IPv4 address monitor
./ipwatch.sh
./ipwatch.sh 4
./ipwatch.sh v4
# For IPv6 address monitor
./ipwatch.sh 6
./ipwatch.sh v6

Use this script for crond job

crontab -e

Add new line to create crontab jobs.

# check ip every 5 minutes
*/5 * * * * /SCRIPT_WORKING_PATH/ipwatch.sh
# OR
*/5 * * * * /SCRIPT_WORKING_PATH/ipwatch.sh v6

What you have to do?

Change the function DoSomeThing():

# What you want to do as the main business?
function DoSomeThing(){
    XLOG "(•••)IP changed.....Let's do something!"
    # .... Add your own code below:
    # curl ....
    # ...
    return 0
    #return customized_number
}

Any output?

./ipwatch.sh 4


113.128.45.218


()Got current Internet IP:113.128.45.218
(i)13.128.45.218-->113.128.45.218


(•••)IP changed.....Let's do something!
(√√√)Job succeed!

(>>>)Caching this new IP:113.128.45.218

Files generated

  • ip.tmp.{hostname}.ipwatch_v4:File stored temp/current IP Address
  • log.{hostname}.ipwatch_v4: Script running logs
  • ip.cache.{hostname}.ipwatch_v4: File stored cached IP Address

How to download

wget https://raw.githubusercontent.com/uf1y/\
do-something-when-your-internet-ip-changed/main/ipwatch.sh

curl -o ipwatch.sh https://raw.githubusercontent.com/uf1y/\
do-something-when-your-internet-ip-changed/main/ipwatch.sh

About

Linux Bash shell script to help you do something when your Internet IP Address changed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages