How to implement Scheduled Scripts
-
I'm a bit new to server stuff and am having trouble with understanding how to schedule a script to run weekly. I want to send each user an email of their weekly progress.
I have it currently set up to send them an email once a week by checking when the leaderboard needs to be reset. But this is not using cloud code scripting and they are required to open the app (which then checks the leaderboard reset time, which triggers a email to be sent) to do this. Is there any clear explanation setting up scheduling scripts and having them automatically repeat weekly?
Thanks -
Hi,
The general approach is to have your script re-schedule itself immediately when it runs (before it does the rest of it's processing).
So then - you just schedule it to run the first time... and each time it runs it re-schedules itself to run again.
You want to re-schedule the script immediately before you do the rest of the processing - so that if there happens to be an error in your script - the rescheduling still happens... (otherwise your weekly cycle would stop).
I hope that helps!
Paul.
-