Cron Bad Minute Error: "home.cron":0: bad minute crontab: errors in crontab file, can't install

19,582

Solution 1

According to crontab.guru both * * * * * and *\1 * * * * are essentially the same thing although you may want to try the alternative just in case your system does not like one or the other.

However in your posted home.cron the path is wrong.

This:

* * * * * /users/username/desktop/forTrump/script.sh 

should be:

* * * * * /Users/username/Desktop/forTrump/script.sh

However if the script requires elevated privileges then you will need to use the root crontab and the line used is slightly different due to the addition of a user column before the command like this:

* * * * * root /Users/username/Desktop/forTrump/script.sh

To install that script as root first switch to root like this:

sudo su

followed by:

crontab home.cron

Also seeing you are on Mac OS X make sure the line in home.cron is terminated with just \n and not \r or \n\r

See also: https://www.dougv.com/2006/12/fixing-a-bad-minute-error-message-when-trying-to-use-crontab-with-certain-unix-text-editors/

This problem most often occurs because you’re using a text editor, such as pico, that fakes word wrapping by adding a newline when it reaches a certain column position.

Crontab delimits jobs with line breaks (newlines). Each job occupies one line. Therefore, if crontab sees anything other than an integer in the first column of a line, it throws the “bad minute” error, since the minute argument is the first one crontab encounters.

The simple fix is to go to delete the line breaks added by pico / your *nix editor. You can most easily do that by putting your cursor on the first character of each extra line, then hit the backspace key until that line is joined back up with the previous one, and repeating the process until your entire cron command is on one line.

Solution 2

I have encountered with similar issue today: "/tmp/crontab.vjQAiZ" 1L, 14C written crontab: installing new crontab "/tmp/crontab.vjQAiZ":0: bad minute errors in crontab file, can't install. Do you want to retry the same edit?

Same error was raised even I tried to add ABSOLUTELY correct entry in my crontab list. As usual I have leart google advices. But notihng has helped.

The solution in my case: 100% usage of /var/log/ directory. It looks like cron can't update own logs and therefore writes similar error when you would like to save your changes.

When I deleted extra log files, issue was solved.

Good luck!

Solution 3

This error (especially if the error indicates that the invalid minute is at column 0) will also occur if the volume where cron files are stored is out of space.

Solution 4

In my case I got this error inside a docker container. The reason for the error is that there was an empty line at the bottom of the file, removing which the issue went away.

Share:
19,582
Sorry
Author by

Sorry

Updated on June 05, 2022

Comments

  • Sorry
    Sorry almost 2 years

    I am creating the cron on Mac OS Terminal, here is the code:

    contents of home.cron:

    * * * * * /users/username/desktop/forTrump/script.sh
    

    then I run it like this:

    crontab home.cron
    

    then I get this error:

    "home.cron":0: bad minute crontab: errors in crontab file, can't install

    Here is the shell file that is opened above, I tested and this runs perfectly by executing ./script.sh from os terminal but I can't seem to run it in cron w/o getting that error.

    #!/bin/sh    
    python /Users/username/Desktop/forTrump/test.py
    

    I already ensure that there were no line breaks causing the bad minute error, thanks in advance for your help.

  • Sorry
    Sorry about 8 years
    I created the script.sh file in text wrangler and can verify there are no extra lines.
  • Reto
    Reto about 8 years
    Then cat -v your crontab to check for unintended control characters.
  • Reto
    Reto about 8 years
    I dont know where OSX actually stores its crontabs. Should be /var/at/tabs - so you would have to run cat -v /var/at/tabs/home.cron
  • Tim Penner
    Tim Penner about 8 years
    what is the line terminated with?
  • Sorry
    Sorry about 8 years
    This is the line exactly: #!/bin/env bash echo /Users/jamalrabie/Desktop/forTrump/test.py
  • Sorry
    Sorry about 8 years
    Here is what I get Reto, usage: sudo -h | -K | -k | -L | -V usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid] usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u user name|#uid] [-g groupname|#gid] [command] usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>] usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ...
  • Reto
    Reto about 8 years
    Have you tried */1 * * * * /Users/username/Desktop/againstTrump/script.sh Users and Desktop?
  • Reto
    Reto about 8 years
    cat -v /var/at/tabs/home.cron not -v /var/at/tabs/home.cron ;)
  • Tim Penner
    Tim Penner about 8 years
    using TextWrangler check the line endings in home.cron and make sure they are just \n
  • Sorry
    Sorry about 8 years
    I tried that, same error, oh and btw the above is what I got for cat -v
  • Sorry
    Sorry about 8 years
    That is what is in the shell file "script.sh", this is in home.cron: */1 * * * * /users/username/desktop/againstTrump/script.sh
  • Reto
    Reto about 8 years
    Under Linux -v option of cat is the equivalent of cat --show-nonprinting Your output appears to be the one of sudo -v
  • Sorry
    Sorry about 8 years
    Hi Tim, thanks for the advice, I don't get the error any more by deleting weird words in cron file, but the script does not run, when I execute ./script.sh it is fine, but it does not work with cron like this: */1 * * * * /Users/username/desktop/forTrump/script.sh
  • Sorry
    Sorry about 8 years
    you are are right, i used sudo because permissions were denied.
  • Tim Penner
    Tim Penner about 8 years
    check the case sensitiveness of the path: /Users/username/desktop/forTrump/script.sh should be /Users/username/Desktop/forTrump/script.sh
  • Tim Penner
    Tim Penner about 8 years
    @Sorry I made the last point more clear in my answer and supplied an example of what the path should look like in your home.cron
  • Sorry
    Sorry about 8 years
    Hi Tim, I ensured it was case sensitive, but no luck. The issue maybe this: I tried running the script.sh stand along and I am getting permission denied from os terminal.
  • Tim Penner
    Tim Penner about 8 years
    @Sorry, see my updated answer including: if the script requires elevated privileges then you will need to use the root crontab and the line used is slightly different due to the addition of a user column before the command like this: * * * * * root /Users/username/Desktop/forTrump/script.sh To install that script as root first switch to root like this: sudo su followed by: crontab home.cron
  • Sorry
    Sorry about 8 years
    The error went away after I prepended python to the shell file so: #!/bin/sh python /Users/username/Desktop/forTrump/test.py, you got me this far though, so thank you for the help!
  • Sedat Kestepe
    Sedat Kestepe almost 6 years
    I came upon the same thing as log partition /var was out of free space. Until then I couldn't find what the problem was.