In this part of the documentation we will install the script as a cronjob in crontab so it executes automatically at given intervals.
All pages in this serie:
Steps on this page:
Start the crontab editor on your SSH session with the command:
crontab -e
The first time it should ask which editor you want to use (if there are more than one installed). I would advise to use Nano because it operates quite user friendly.
In my case the crontab editor always automatically starts with Vi as the text based editor where my favorite is Nano.
You can set the editor back to Nano until the next cold start or reboot with the following command:
export EDITOR=nano; crontab -e
By the way:
When you're struggling to get vi closed:
In all other cases you can start crontab simply with the command:
crontab -e
What to enter in crontab depends on a few things:
In the example below I assume you will run the script on the whole hours and on the half hours. Also I used the example path /data/local/ip-logger in the following example.
You can enter the following on crontab:
0,30 * * * * /data/local/ip-logger/ip-logger.sh
Important! Always end with a blank new line!
When you want to execute the script every 10 minutes you can enter the following on crontab:
*/10 * * * * /data/local/ip-logger/ip-logger.sh
Important! The script reads your external IP-address from the website ipecho.net. Please do respect their effort and do not abuse their website by requesting your IP-adres to much! The lowest interval that would be friendly to them is 10 minutes I think.
For more information on how to use crontab you might find the following resources usefull:
After this the script should run automatically on the provided interval. When you enabled logging you will be able to check it at the logs.
Proceed to IP-logger - Part 5: Done!