Cron execution slightly delayed - normal?
I have a script which runs every 30 minutes via Railway's Cron support, in order to execute jobs at a specific time. The script contains multiple functions and determines which to run based on the time. I initially checked for the exact minute and hour i.e. 30th minute of 8th hour, but noticed that often the appropriate function would not execute because the actual execution of the container was after the 0th/30th minute. It seems to take some time from the start of the Cron trigger and the actual execution of the code, about 90 seconds.
Example from Deploy Logs where container executes after 1:10 has passed:
Current time: Wed, 07 Aug 2024 22:01:10 GMT
Is this normal? Does it have to do with Railway building a fresh container for each cron execution?
I have temporarily resolved the issue by giving the script's functions some wiggle room (~5min) but ideally if I want the script to run a certain function at 8:30, it should run at 8:30 or as close as possible.9 Replies
Project ID:
7440ea60-c734-47cc-ba5d-e8cabf480488
7440ea60-c734-47cc-ba5d-e8cabf480488
please see the answer to this thread - https://discord.com/channels/713503345364697088/1263516039208112178
Thanks for the info. I'll see if it becomes an issue as it is. The script is run with bun. In your opinion, would converting the script to bash potentially improve the execution time?
this is not about the language you are using, this is simply that railway's cron jobs do not guarantee minute accuracy
If I understand correctly, language doesn't matter because no build step is involved in repeated Cron executions? My line of thinking was that if I rewrote it in bash and specified a minimalist base image, it would build and thus execute faster.
right no build step as the last snapshot is ran, railway's cron jobs do not guarantee minute accuracy, aka they might not start your job until 22:01:00 UTC
got it, thanks man. i'll keep the script in JS for now.
if you need ultra accurate cron jobs, you would want to use an in-code schedular