payload cms scheduler

default discord avatar
7 months ago
1 2

I would ask if there is a standard approach for automatic, reoccurring actions in Payload? For example, when user is inactive since 7 days, deactivate him or similar things.

  • discord user avatar
    Payload Team
    7 months ago

    We use node-cron in our public demo to clear the database and re-seed data every hour. Might be a good example to look at.

  • default discord avatar
    7 months ago

    I believe there's no built-in way to do that on Payload, however, since it's built on top of express and Node.js you are able to implement cron jobs and use the Payload Local API to achieve what you're looking for.

    You can look into node-cron for a simple cron job implementation in Node.js.

    For the use case you mentioned, maybe you can run a cron job once at the beginning of every day to check for any inactive users since 7 days or more and suspend them using the Payload Local API.

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.