javan / whenever

Cron jobs in Ruby
MIT License
8.83k stars 727 forks source link

whenever command should default to --update-crontab #642

Open MartinNowak opened 8 years ago

MartinNowak commented 8 years ago

Right now it's really easy to overwrite everything else in your crontab by just running then whenever command. Since the crontab entry already has delimiters (also used by the --update-crontab option) to just update the section that belongs to whenever, one would expect this to be the default behavior. Please change the default behavior of the command and add an optional --overwrite-crontab instead.

ttilberg commented 4 years ago

I just did this and quite unexpectedly overwrote my crontab... :| The --help content was not helpful in guiding me away from this.

Usage: whenever [options]
    -i [identifier],                 Default: full path to schedule.rb file
        --update-crontab
    -w, --write-crontab [identifier] Default: full path to schedule.rb file
    -c, --clear-crontab [identifier]
    -s, --set [variables]            Example: --set 'environment=staging&path=/my/sweet/path'
    -f, --load-file [schedule file]  Default: config/schedule.rb
    -u, --user [user]                Default: current user
    -k, --cut [lines]                Cut lines from the top of the cronfile
    -r, --roles [role1,role2]        Comma-separated list of server roles to generate cron jobs for
    -x, --crontab-command [command]  Default: crontab
    -v, --version

The part about --update-crontab isn't obvious, as it is tied to an identifier option. I get the impression that -i actually means install instead of --identifier? This was not obvious. I looked at https://github.com/javan/whenever/blob/master/bin/whenever to see if it made more sense, and I see that identifier is an optional arg.

I think:

Edit: Perhaps this is a slightly different issue: I didn't run whenever on it's own -- that displays the parsed cron, which is helpful. But it wasn't obvious that I should run whenever -i (--install ?) instead of whenever -w.