Don't think you will receive much help without even providing the model of the router in question. However, I guess writing a script to telnet/SSH into the router and executing the restart command would be fairly trivial. Provided that the router actually does support these options that is. Start with manually logging in to the router in this manner and rebooting it, while recording all the needed command for this. After this do some reading up on bash scripting and I am sure that you will be able to write a script yourself.