R
Railway

✋|help

Docker Service CRON Restart?

Aayushlal8/20/2023
Hi guys, i have a single docker service running. I'd like to restart this service periodically via the Railway CRON functionality. Is this achivable? I am not too sure how to get my container_id

0 0 * * * docker restart <container_name_or_id>
Aayushlal8/20/2023
N/A
Aa_dumb__8/20/2023
Unfortunately that’s not what Railway’s cron jobs are built for. What you can do though is set up a function in your code that quits your program according to a cron schedule and set your service to restart after quitting in Railway settings
Bbrody1928/20/2023
I've made a template for the exact functionality you would like, but it's not quite ready for public release, would you like me to share it when it's ready?
Aayushlal8/21/2023
@Brody that would be awesome thank you very much!
Bbrody1928/21/2023
so just to be clear, you just wanna restart your service on a cron schedule?
just the same as clicking the 3 dot menu on the deployment and clicking restart?
Aayushlal8/21/2023
@Brody Correct
Bbrody1928/21/2023
gotcha, i just need a good template icon at this point lol
I'm not joking, I have no idea what to use as the icon, got any ideas?
Aayushlal8/21/2023
so what exactly is the template? is it generic template that will restart any service/project? Or only certain types i.e. docker, node etc?
maybe like an hour glass figure?
Bbrody1928/21/2023
it can restart any railway service, doesnt matter what the service is
Aayushlal8/21/2023
i kinda like the hour glass figure but idk?
Bbrody1928/21/2023
ill see what i come up with, thanks!
Kkingoiscool8/21/2023
@Brody I am also interested - was looking for this exact functionality a few weeks ago
Bbrody1928/21/2023
ill keep you both posted
Solution
Bbrody1928/21/2023
Aayushlal8/21/2023
Amazing thank you! Will give it a shot
Bbrody1928/21/2023
let me know if there are any difficulties
Aayushlal8/21/2023
just set it up now on my project. I have a schedule to restart my service at 12am AEST (roughly 7 hours from now).

Will let you know how it goes
Bbrody1928/21/2023
awesome, how easy was the setup?
Aayushlal8/21/2023
Very easy but i had no idea bookmarlets was a thing lol 😂
Bbrody1928/21/2023
also, I don't know if I mentioned it in the readme, but the services cron schedule runs on UTC time
Aayushlal8/21/2023
oh gotcha makes sense. Will cater for that
Bbrody1928/21/2023
even railways native cron is utc
you can just edit the cron expression in the variable and let the service redeploy
Aayushlal8/21/2023
sweet thanks
fixed it up now, 0 12 * * * should be 12am AEST
Bbrody1928/21/2023
possibly, I don't actually know how to read a cron expression lol
Aayushlal8/21/2023
neither lol, im relying on chat gpt 😄
Bbrody1928/21/2023
but you'll get an error message in the deployment logs if the cron expression is invalid
Bbrody1928/22/2023
that's a calendar?
did someone ping me?
Aayushlal8/22/2023
@Brody looks to be working!
Aayushlal8/22/2023
Thanks heaps for that template
Bbrody1928/22/2023
no problem, and if you run into any issues, let me know

Looking for more? Join the community!

Recommended Posts
Can't set a private project to publicWhenever I try to set a private project to public, I get the error "All services in a public projectcan railway forward traffic to a self signed web application?i'm deploying an application and for some reason it needs to use self signed certificate, could railPrisma timeoutI am trying to use a fairly large query with Prisma and get `Timed out fetching a new connection frI want to run AirbyteI would like to use an ETL and I heard that Airbyte is good so I'm trying to set it up as a service NestJS application doesn't startHi, I'm trying to deploy a NestJS app but it gets stuck on a loop trying to start the server. I thiSQLite DatabaseIm trying to deplay a discord bot that uses an sqlite database. Ive created a persistent volume for About storageHello I'm newbie here, i just wanted to know how much storage will i have with the hobby plan?, I anode_modulesI'm trying to deploy using my build script. The build script consist in install normally the packageDefault Express template fails to deployHi, I've tried to deploy the ExpressJS template with no modifications, but am getting errors. Thx foQuestions about pricing for my customersHi, I'm planning to open a web agency and use Railway to deploy our customers' websites. Each customRailway IPv4Guys, does Railway "exports" IPv4 to another service allow its usage permission? I'm using a Redis s[PHP] Route all requests to index.phphttps://twitter.com/Shpigford/status/1693092242943025554I can't buy the planWhen I try to subscribe to the $5 plan, it gives me an error message saying "Your card does not suppI have a problem with my express applicationin the application status it says success but it is not displayed on the websitewhat is the reason for this error?npm WARN config production Use `--omit=dev` instead.Subscription already existsI can't enable the developer plan, the system returns the message: "Subscription already exists"FLASK APP failed to deployI used the refernce flask project idk why maybe the build/run command i put in was incorrect?503 error after binding to ipv6I get a 503 error after binding to ipv6 for internal communication between 2 services. attached my How do I link my services internally?Hello, I tried to figure it out on my own, but I have just ended up losing sleep haha. I'm having anBuild fails when pushing a project with docker-compose file.I am trying to link a project from cli and trying to push it to railway. i am using a docker compose