# How to run a function exactly once on each node?

**URL:** <https://discuss.ray.io/t/how-to-run-a-function-exactly-once-on-each-node/2178>\
**Category:** Ray Core\
**Created:** [May 17, 2021, 5:09pm UTC](https://discuss.ray.io/t/how-to-run-a-function-exactly-once-on-each-node/2178 "2021-05-17T17:09:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mannyv](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/mannyv/32/606_2.png) [@mannyv](https://discuss.ray.io/u/mannyv)\
**Post date:** [May 17, 2021, 9:03pm UTC](https://discuss.ray.io/t/how-to-run-a-function-exactly-once-on-each-node/2178/2 "2021-05-17T21:03:36Z")

</div>

Hi @dutch,

Check out this recent post for one way to address this problem.

> [@How to create @ray.remote jobs that will only run on the workers from the local node?](https://discuss.ray.io/t/how-to-create-ray-remote-jobs-that-will-only-run-on-the-workers-from-the-local-node/868/2):
>
> One possible solution is to specify the custom resources on a node that has files; ray start --resources=’{“files”:1}’ @ray.remote def f(): pass ray.get(f.options(resources={"file":0.001})).remote()

---

_[View the full topic](https://discuss.ray.io/t/how-to-run-a-function-exactly-once-on-each-node/2178)._
