You can use hixxy's code to start it after closing the socket. Just put a timer on the sockopen he put near the end of the script.
.timermyb 0 5 sockopen myb
www.erepublik.com 80
You can adjust the 5 to whatever number of seconds you want to let it wait before repeating.
Then, to end the timer, use:
/timermyb off