CRON Schedule a Docker Container
samliew94
HOBBYOP

a year ago

Hi. I have a usecase for a client where I need to schedule the backup of MongoDB and Cloudflare R2.

My thought process:

  1. Create a NodeJS app with node-cron & shelljs (to run UNIX commands) installed.
  2. Write necessary shell commands in cron.schedule e.g.:
    1. shell.exec('command to backup mongo...')
    2. shell.exec('command to backup r2...')
  3. Dockerize with a Dockerfile that installs the necessary CLI tools to backup MongoDB (MongoDB CLI DB Tools) and R2 (rclone).

I can run the container and it'll work, sure. But I only need to run the shell commands once a day.

Leaving the container to run 24/7 doesn't seem ideal.

Is there anyway I can schedule the container to startup and stop daily?

1 Replies

a year ago

Hello,

Ditch node-cron and use our native CRON scheduler!

https://docs.railway.com/reference/cron-jobs


Welcome!

Sign in to your Railway account to join the conversation.

Loading...