Cron service shows no application logs, only "Starting Container"
jgsp1
HOBBYOP

4 months ago

I have a cron service that runs daily. The Railway UI shows the service status as "Running" during execution and eventually completes, but no application logs appear in the Railway dashboard or via railway logs. The only line shown is:

Starting Container

No stdout or stderr output from my Node.js application is captured. Without logs, I can't tell if the application is actually running or silently failing. The same Docker image runs fine locally with full log output.

Service configuration (railway.toml):

[deploy]

startCommand = "Xvfb :99 -screen 0 1280x720x24 >/dev/null 2>&1 & export DISPLAY=:99 && echo 'Container started, launching sync...' && exec node

dist/scripts/fullSync.js"

cronSchedule = "5 13 * * *"

Runtime: Node.js on mcr.microsoft.com/playwright:v1.57.0-jammy (Dockerfile-based deployment)

What I've tried:

1. stdbuf --output=L — line-buffered stdout wrapper → no logs

2. process.stdout._handle.setBlocking(true) — force synchronous writes in Node → no logs

3. fs.writeSync(1, ...) — bypass Node's console.log entirely and write directly to fd 1 (stdout) and fd 2 (stderr) → still no logs

4. The echo in the start command itself (echo 'Container started, launching sync...') — also doesn't appear, only Railway's own "Starting Container" message shows the fact that even a plain shell echo before exec node doesn't appear suggests this isn't a Node buffering issue. Railway's log collector may not be capturing output from cron service executions.

Expected behavior: stdout/stderr from cron job runs should appear in the service logs, the same way they do for always-on services.

Questions:

- Is there a known limitation with log collection for cron-triggered services?

- Is there a different way to view logs for cron executions (e.g., a specific deployment/execution view)?

- Any recommended workarounds?

$10 Bounty

3 Replies

abhi-apple
FREE

2 months ago

The root cause is most likely Railway's log collector not attaching to cron containers fast enough. Two

clues confirm this:

1. Even your plain echo before exec node doesn't appear — so it's not a Node.js buffering issue at all

2. The same image logs fine locally — so your app is writing to stdout correctly

What's happening: Railway spins up the cron container, but the log pipeline takes a few seconds to

connect. By the time it's ready, your early output is already gone. And exec node replaces the shell

process (PID 1), which can cause Railway's log tracker to lose the stream entirely.


abhi-apple
FREE

2 months ago

Try this combination in your railway.toml:

startCommand = "sleep 5 && Xvfb :99 -screen 0 1280x720x24 >/dev/null 2>&1 & export DISPLAY=:99 && echo

'Container started, launching sync...' && node dist/scripts/fullSync.js 2>&1"

Two changes from your current setup:

1. sleep 5 at the start — gives Railway's log pipeline time to attach before any output

2. Removed exec — keeps the parent shell alive as PID 1, which Railway tracks more reliably

The 2>&1 at the end ensures stderr also goes to stdout so you see errors too.


abhi-apple
FREE

2 months ago

If the one-liner still doesn't capture logs, move to a wrapper script. Create entrypoint.sh in your

repo:

#!/bin/bash

set -e

sleep 5

Xvfb :99 -screen 0 1280x720x24 >/dev/null 2>&1 &

export DISPLAY=:99

echo "=== Sync started at $(date) ==="

node dist/scripts/fullSync.js 2>&1

EXIT_CODE=$?

echo "=== Sync finished at $(date) with exit code $EXIT_CODE ==="

exit $EXIT_CODE

Then update railway.toml:

startCommand = "bash entrypoint.sh"

This gives you clean start/end timestamps in logs and keeps everything in one trackable process. The

wrapper script is also easier to debug and modify than a long one-liner.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...