Sign In Register

How can we help you today?

Start a new topic

Cannot schedule bulk job from system scheduler?

Tried calling Spark.getBulkScheduler().submitJobModule() from inside one of the system scrips (everyHour, everyMinute) and received this error:

"You cannot schedule a bulk job from this script"

Is that expected?  I had only placed it in everyMinute to test the logic  - the goal was to place it in everyHour - but even then, it was conditional - would only schedule a bulk job on a certain hour of the day.



2 people have this question

Hi Jeff,

Yes this is the expected behavior here. You can't schedule jobs within the system scheduled scripts. Its to protect from jobs piling up and causing a heavy load on the clusters. What are you trying to schedule in the every hour script ? If you can give us an idea of what you need here we can point you in the right direction I'm sure.



Again - I was simply using the everHour script to execute a bulk job that I needed to actually run every couple of weeks - but at a specific dynamically determined time (related to seasonal tournament notifications to players).

Note that I WAS able to make this work by creating a new SparkRequests.ScheduleBulkJobAdminRequest() and calling Send() on it.... (inside the everyHour script). 

Hi Jeff,

We're going to try to replicate this. We'll get back to you soon.



Hi Jeff,

I managed to replicate this and you are right. It would appear that it can be sent using a SparkRequest. I'm awaiting confirmation but for now I would hold off using this as it may have its usage removed from those scripts. For now you could use the Every Day script and check what day it is. If it's the correct day you can schedule a module to run at a specific time that day.


//get the day
var day = new Date().getDate();

if (day == 20){
//schedule your module to run

If you have any further questions just let us know.  



The issue is not with the timing (although I still need to use every-hour - because the season-end can be at any hour/day depending on a very dynamic setup) - but instead with being able to kick off a bulk-job request THROUGH the system EveryXXX scripts.  

Hi Jeff,

Using the ScheduleBulkJobAdminRequest in this way would not be recommended here. BulkJobs were never intended to be used from these system scripts. Using the Scheduled module method outlined above would likely be the best course of action here. Is there a reason why you feel a bulkJob is the best way to achieve what you need here ?



I need to kick off a bulk job (that does exactly what a bulk job is designed to do - iterate over large swaths of players and execute cloud code...logic that could take over the normal cloud code execution time limit en totem) - but I need to do it NOT by manually kicking off the bulk job - but dynamically when the calendar/clock hit certain milestones (dynamically determined).

Hi Jeff,

I understand where you're coming from here but the ScheduleBulkJobAdminRequest wouldn't be the right way to go about this. I think if we had more details about exactly what would be executed and who it would be executed on we could help point you in the right direction here. We can convert this to a ticket if you'd prefer to discuss it privately ?



Just came across this thread as I needed exactly the same functionality as Jeff.

I have leaderboards and events in the game which are not just WEEKLY or MONTHLY or DAILY. I need reset them is times defined by me and automatically. Therefore I cannot give rewards to players in these leaderboards by using Achievements Triggers. So I tried to give rewards to these players by using bulk jobs in system time scrips . Specifically I am using "Every_Hour" script, where I check if it is the right day and hour of the day and If it is,  I call the bulk job to give players reward. And it works. 

Therefore I want to ask here, whether it is a correct way of doing these kind of things as I could not find any other solution and I also do not want to do "some bad things" to the service.


I am in a similar situation as the previous posters.

I want to improve on how players are notified that there's a new game build available to them via Steam. To accomplish this, I intend to mirror the Steam backend's information on available client build versions into my GameSparks backend, and use a combination of polling and notifications to deliver notifications to clients when there is a new update available.

One part of this process is to regularly (once per minute, if feasible) run a scheduled job which fetches the latest version information from Steam and stores it into GameSparks.

Then, whenever the GameSparks backend discovers that there is a new build available, it should send a notification to all connected clients that run an older build. My current plan was to run a Bulk Job - but then we are in a situation where a scheduled job needs to run a bulk job -> no go.

One compromise that could work, could be to have a recurring per-player module scheduled using SparkScheduler; as soon as a player goes online, the module containing "check if there is a new version available, and inform player if so" logic is scheduled in 1 minute from now, and when it runs, it will schedule a follow-up module a minute later, etc, ad infinitum, until the player is no longer online.

Hmm. Is that how you would prefer to avoid the bulk job in a situation like this? Or would you suggest a different solution?


So apparently that doesn't work either. The 10th time that a scheduled job attempts to schedule up a follow-up job, GameSparks emits the following error: "You can only chain the scheduling of 10 scripts. The script with the shortCode SchedulerModule_NotifyPlayerIfNewBuildIsAvailable was not scheduled".

This is the second implementation that does not work because of limitations which I was unaware of.

At this point, the only solution I know of, that will work, is:

* Run a recurring job on another platform (for example Google Cloud).

* Let the recurring job invoke a callback in GameSparks, say, once a minute.

* Let the callback in GameSparks schedule a bulk job for immediate execution. The bulk job will be run for all players that are currently online and are not yet marked as 'has already been notified'.

* In the bulk job, check if there is a newer build available for the current player. If so, mark the player as 'has been notified' and send a notification down to that player's game client.

This is not in the spirit of the platform, but then, I'm out of ideas that could be in the spirit.

The manual clearly states that it is possible:

Bulk Jobs for Scheduled Scripts?
 Scheduling bulk jobs are available to use with the GameSparks scheduled scripts under System scripts for Every DayEvery Hour, or Every Minute. You can schedule one bulk job per scheduled script. Note that if a job is currently running, then a new one won't be scheduled. Therefore, if you use the Every Minute scheduled script, you might get a "You can only schedule one script" error, because the previous one hasn't finished running.

Yet, I'm getting: 
2019-03-11T14:02:02.249Z ERROR GS_MINUTE "You cannot schedule a bulk job from this script. The bulk job was not scheduled."

So it's possible or not?

Login to post a comment