Server side scripts have a simple mechanism how to run your code in a given interval. If you want to run your code after some delay, use the setTimeout function. If you want to run your code repeatedly, use setInterval. You can use the dialog to add new timer. It is located in the script window toolbar:
You will be presented with the Timer dialog:
When you click on “OK”, you will have a periodic timer created.
This code will be run periodically every minute.