Docker Service CRON Restart?
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
32 Replies
Project ID:
N/A
N/A
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
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?
@Brody that would be awesome thank you very much!
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?
@Brody Correct
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?
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?
it can restart any railway service, doesnt matter what the service is
i kinda like the hour glass figure but idk?
ill see what i come up with, thanks!
@Brody I am also interested - was looking for this exact functionality a few weeks ago
ill keep you both posted
Solution
@Ayush @Kingo - https://railway.app/template/fwH-l3
Amazing thank you! Will give it a shot
let me know if there are any difficulties
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
awesome, how easy was the setup?
Very easy but i had no idea bookmarlets was a thing lol 😂
also, I don't know if I mentioned it in the readme, but the services cron schedule runs on UTC time
oh gotcha makes sense. Will cater for that
even railways native cron is utc
you can just edit the cron expression in the variable and let the service redeploy
sweet thanks
fixed it up now, 0 12 * * * should be 12am AEST
possibly, I don't actually know how to read a cron expression lol
neither lol, im relying on chat gpt 😄
but you'll get an error message in the deployment logs if the cron expression is invalid
that's a calendar?
did someone ping me?
@Brody looks to be working!
Thanks heaps for that template
no problem, and if you run into any issues, let me know