#Rails rake tasks from a cron job?
24 messages · Page 1 of 1 (latest)
Maybe my issue is trying to do the cron job on the same service? The other issue I’m having is it’s hard to monitor. It seems to be silently failing and I’m not sure where to look for logs to troubleshoot.
Would you mind explaining what you mean by “run it on an internal”?
You know, if I knew what I meant yesterday I absolutely would
I'd recommend using CMD + K -> New Service, then deploying only the cronjob (using the NIXPACKS_START_CMD variable) to just whatever the cronjob runner start is
Should I deploy the same GitHub project for the cronjob-only service? Or will it somehow have access to my web service?
Should be able to just deploy the same codebase and set a different start command
(Maybe internal server? Just a wild guess haha).
Is it possible to have my cron job log to the deployed service log? Like can I append to a certain log file and see it on the Railway service logs. Debugging silence is the hardest part.
Wouldn’t you want like, separate logging so you don’t bury the cron logs in your service logs?
I don’t quite understand how it’s “silent”
I’m not sure how to view any logs other than the one that shows in the service dashboard and ‘railway logs’ cli
Can I have your projectID?
You should have 2 services, and each one should be its own log stream
I don’t think cron jobs output anything to the main log though. I’ll grab the project ID when I get back to my computer.
You should have 2 services, and you should run 1 process per service
OK, here's my projectID 821aa0a3-8233-4cfe-a213-157dc35a48e2. I have a service named cron dedicated to running the scheduled jobs.
I'm still struggling with debugging seemingly silent cron jobs. Wheat I mean by that is if I have a crontab entry
* * * * * /bin/bash -l -c 'echo "Hello, app!"'
"Hello, app" does not appear anywhere in the Railway logs and therefore if that were a rails job instead, I would have no idea if there is an issue with the crontab or if the rails job if failing for some other reason.
as far as I can tell, the whenever gem I mentioned previously is working fine. I am seeing a log message [write] crontab file updated which is what I expect the whenever update-crontab command to do, but I have no evidence that the cron service is running or doing anything
I'm trying to do this using the whenever gem. I created a new service and tried to set the start command to whenever --update-crontab under Settings > Start Command.
When I hit the check mark, nothing happens, no error messages, but it does not save. Thoughts?
Hi! I've got this same question. What's the solution in the end?
Question how? Hard for me to interpret what you are asking for. Issues with cron or issues with setting start command.
Sorry. What I’m in need of is running cronjobs on a Rails app
We've got a guide on it 🙂
A brief guide on deploying and running cron jobs on Railway using JavaScript.