简体   繁体   中英

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

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.

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!

如果存储 cron 文件的卷空间不足,也会发生此错误(尤其是当错误指示无效分钟位于第 0 列时)。

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.

When exactly shall your cron job run - every minute?

m h dom mon dow command
*/1 * * * *  /users/username/desktop/againstTrump/script.sh

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM