Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
chruby from cron #219
The wiki page on cron suggests you can just put
But when I try this, I get a "/bin/sh: chruby-exec: command not found"
Maybe because the
So I thought I'd try:
But that still gives me:
From an interactive shell as the same user that cron is running on, I can definitely access
Okay, continuing to investigate and try to answer my own question, I see chruby-exec is not a shell function, but is actually installed at
So why wouldn't this be in my path on a cronjob, even with
I'm having trouble figuring that out. If I run:
But if I make a cronjob:
Then indeed the PATH does not include /usr/local/bin.
I realize this is more a unix issue than a chruby issue, but this is perhaps something people other than me are likely to run into trying to use chruby in a cron? You definitely have more shell scripting knowledge then me, do you have any suggestions or places to investigate? would appreciate any tips.
Okay, I found your suggestion that chruby-exec is really just syntactic sugar:
So trying this in a cronjob:
That DOES appear to work for me in a cron! I guess I'll use that? Does chruby-exec work for most people on other distros in cron, cause they have
i wonder if the wiki page should be altered to warn you about $PATH issues, and/or suggest
oh man, this is so confusing, trying to switch my uses of chruby-exec to just chruby X && caused other issues I still havne't debugged in other areas.
Ah, my other issue is that a ruby wrapper script I had ran some shell commands with ruby
Man. I guess I could change my system() to do
Would definitely appreciate some advice based on your shell expertise (better than mine) and current understanding of best way to do all these things, @postmodern.
Now I don't know if I should leave chruby-exec but make sure to explicitly set the PATH in my crontab -- but that might break when you refactor chruby-exec to be a shell function, as you keep suggesting you will soon in various tickets, etc.
Weirdly, even spelling out
Get me a:
I can't figure out how /bin/sh even got involved there , to not be able to find 'chruby'. I'm explicitly running it all in a
Man, this stuff is confusing. I liked chruby's simplicity over even rbenv... but I had cron jobs working using rbenv, and can't seem to figure out how to get them working with chruby.
Sadly, it doens't look like you can do the "PATH=$PATH:/usr/local/bin" trick, so i can't just add /usr/local/bin on to what's already there, need to duplicate what's already there, which requires figuring it out somehow. Phew.
Anyhow, would it make sense to add this tip to the wiki page?
And is chruby-exec still your recommended method for cronjobs at the moment? Various comments in issues show that you're thinking has gone back and forth on this sometimes.
You'll only need to ensure
I am not using a global crontab, I don't think. I am using a partiuclar account's crontab.
That particular account does have chruby enabled, in it's
Nonetheless, I'm still getting
Hmm, I see, because maybe it's calling
What's actually going on is even more confusing and complicated than this, I've tried to simplify. But okay, I'll have to keep troubleshooting.
Thanks, your advice is helping. But I would strongly encourage you including more of these tips in the wiki page on chruby on cron. I'm going on 6 hours of working on this even though I'm not a complete idiot when it comes to unix and shells, this stuff gets awfully complicated. It maybe could have saved me a few of those hours to have a few more hints in the wiki page.
(I am trying to change a system that previously used rbenv, in a fairly complicated way, to use chruby. After another 6 hours or so of trying, I'll prob give up and go back to rbenv)