Cron jobs not actually executed
kobu
HOBBYOP

19 days ago

Hey,

I dont think i understand whats going on with the cron scheduler. In my project https://railway.com/project/d59f7154-f04a-44b3-ab8a-ed345e55b209?environmentId=2b2b3a33-4591-49e3-b1b1-9b70d5fd6eb1 i have a rust cron service which is supposed to run daily, and while it reports it does:

image.png

thats not actually the case. Nothing is being logged and instead multiple "Starting container" lines are logged:

image.png

No network calls are made and no errors reported.

At this point im not sure where exactly is the problem. When i tested the docker image locally it worked just fine.

$10 Bounty

1 Replies

Status changed to Open Railway 19 days ago


19 days ago

Railway cron is a bit different from running cron inside the container. It basically starts the container on the schedule, so the service start command needs to be the actual job and it has to run in the foreground.

I’d first make the start command super obvious for one run, something like:

sh -lc 'date; echo CRON_STARTED; ./your-binary'

If CRON_STARTED never shows up, the issue is probably the cron/service start command. If it shows up but your app logs/network calls don’t happen, then the issue is inside the Rust binary or its env vars.

Also check the Rust code isn’t spawning async work and then exiting before the request actually runs. For Railway cron, I’d keep it simple: print one log line at start, run the job, then exit 0 on success or non-zero on failure. No background daemon / local crond needed.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...