I'm about to write a script which execute some ruby scripts in a scheduled manner. Production env: Enterprise's cluster running debian with restricted permissions for users so I don't have permissions to edit cron table files. can I use whenever ruby gem? ruby 1.9.1 Thank you for your answers.
-
what do you mean by "can I use whenever ruby gem?" and if the scripts don't run into permission issues, I dont see why you cant use them – Wasi Nov 06 '12 at 15:59
-
3"Whenever" is a Ruby gem that let you write cronjobs in Ruby. OP's title just looks like he used the "whenever" conjunction randomly in a sentence which might explain the downvotes. – danneu Nov 06 '12 at 16:14
-
3No one "owes" anyone anything, but if people explained their down votes, especially on a question from a new user, the system would work better, and new users might be a bit more inclined to come back. – Dmitri Nov 06 '12 at 17:08
2 Answers
The gem whenever
uses the crontab [CRONTAB FILE]
to write it's crontabs. If configured to setup the crontab for another user it uses crontab -u [USER] [CRONTAB FILE]
. The following excerpt from lib/whenever/command_line.rb displays how the command is generated.
def write_crontab(contents)
…
command = ['crontab']
command << "-u #{@options[:user]}" if @options[:user]
command << tmp_cron_file
…
end
So if the user account which executes the whenever
command isn't able to execute the commands listed above, I'm pretty sure whenever
has no way to work as expected.
The user option can be given like this: whenever --user someone
.

- 4,498
- 7
- 26
- 44
The script that you want to run from crontab will have to run as some user in order to work at all. If you have permission to run a script as that user, then you should also have access to that user's crontab, just not root's crontab. As long as you have that, you should be able to use the whenever gem to create and edit cron jobs for that user's crontab.
If this limitation were not in place, then you would be able to gain root privileges just by running a script via some other user's crontab, and of course you don't want that to be possible.

- 4,195
- 24
- 40