Can you use railway variables in the startup command for a cron job
joesolano
PROOP

2 months ago

I have a cron service setup with a start command

curl -X POST https://${{ APP_URL }}/api/cron/sync -H 'x-cron-secret: ${{ CRON_SECRET }}' --fail --silent --show-error

But it seems that the APP_URL and CRON_SECRET are not getting populated when the command gets executed

This curl is setup as the custom start command on the cron-sync service. If I replace the variables with the correct values the code executes correctly

Solved$20 Bounty

Pinned Solution

2 months ago

Hey, you need to wrap your curl request in a new shell to use environment variables within the start command.

sh -c "curl -X POST https://${{ APP_URL }}/api/cron/sync -H 'x-cron-secret: ${{ CRON_SECRET }}' --fail --silent --show-error"

1 Replies

Railway
BOT

2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway 2 months ago


2 months ago

Hey, you need to wrap your curl request in a new shell to use environment variables within the start command.

sh -c "curl -X POST https://${{ APP_URL }}/api/cron/sync -H 'x-cron-secret: ${{ CRON_SECRET }}' --fail --silent --show-error"

Status changed to Solved uxuz 2 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...