How to schedule the execution of an update_by_query painless script in a cluster

I need to schedule the execution of an update_by_query painless script so that it gets executed in the current Primary shard of the cluster regardless of the nodes of the script that might me down. I think that Kibana console does this behind the scenes but how can I dot it in an automatic way?

There's currently nothing in Elasticsearch to do this sorry to say. You'd need to manage it externally.

Thank you Mark