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

a month 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

a month 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

a month 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 about 1 month ago


a month 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 about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...