Best Way to Run a Weekly Cron Job

Use case: I need to poll an external API during several windows throughout the week. The times change each week and no two will be the same (or very rarely). I know what the upcoming week's times will be by polling an endpoint at a particular time in the current week. This cron job of mine requests data from an external API to compare to data in my networked database and if it detects changes it does things and then updates the database. Current state: Currently, I have the cron scripts start up and queue in my Express app after it deploys but they do not run on schedule in Railway, nor at all. The jobs run at the appropriate time locally and works with my local services without error. Question: Curious to know the best path ahead or perhaps what I'm doing incorrectly when starting the jobs on Railway. I'd prefer not to but if I have to create a separate service for the cron and use Railway's cron settings in the service settings I'll go down that path. Thanks!
Solution:
id recommend creating another service, but continue using bree, separate bree from your express app
Jump to solution
7 Replies
Percy
Percy12mo ago
Project ID: db989257-d5bb-4cba-acd6-bc0aa22606a5
bigviking
bigvikingOP12mo ago
db989257-d5bb-4cba-acd6-bc0aa22606a5
Brody
Brody12mo ago
just so i understand correctly, youre currently using an in code cron schedular right now?
Solution
Brody
Brody12mo ago
id recommend creating another service, but continue using bree, separate bree from your express app
bigviking
bigvikingOP12mo ago
Awesome, thanks Brody.
Brody
Brody12mo ago
no prob!
Want results from more Discord servers?
Add your server