How to fix “Bad minute” error while installing a new crontab

I've installed a fresh Ubuntu 16.04 to replace my Windows OS.

I'm trying to setup cronjobs to run mangento 2.1 via Ampps softaculous. The software has been successfully installed (both ampps and magento) and it's running well. I'm trying to setup a crontab but it seems there is an error on the first line second 25.

This is what I'm trying to add in to the crontab for the Ampps user, using the command sudo crontab -e -u ampps

* * * * * /usr/local/ampps/php-5.6/etc
/usr/local/ampps/www/ cron:run | grep -v "Ran jobs by schedule" >> /usr/local/ampps/www/
* * * * * /usr/local/ampps/php-5.6/etc
/usr/local/ampps/www/ >> /usr/local/ampps/www/
* * * * * /usr/local/ampps/php-5.6/etc
/usr/local/ampps/www/ setup:cron:run >> /usr/local/ampps/www/

What am I doing wrong?

I followed an error message in magento 2.1 admin that referred to this troubleshoot link for the version 2.0and to this configuration guide

5

7 Answers

Each crontab line must start with a time at which the command should be run and then the command. The general format is:

Min Hour Day Month DayOfWeek Command

So, to run command at 10:15 every Sunday, you'd do:

15 10 * * 0 command

I'm not sure what your commands are, but you have lines that don't start with a time definition. I don't understand what lines like this are:

* * * * * /usr/local/ampps/php-5.6/etc

That's a time but no command. You're giving it a directory. And lines like this have commands but no time:

/usr/local/ampps/www/ cron:run | grep -v "Ran jobs by schedule" >> /usr/local/ampps/www/

So, make sure you follow the format and you should be fine. If this is not clear, edit your question and explain what commands you are trying to run.

From my previous experience, it was due to a CR/LF character before the first cron line (since it was edited from Windows not Linux directly). I noticed and removed that char from a HEX editor.

3

This error also happens if your /var/spool/cron partition is 100% full. Check your free disk space and make sure you have a few bytes free there.

This kind of error may also occur if you are trying to reset cron variables to empty values like this:

MAILTO=
* * * * * do some stuff with error reporting
MAILTO=
* * * * * do another stuff too verbose to receive emails

Note the empty line after MAILTO= at line 3. This will result in the message:

crontab: installing new crontab
"/tmp/crontab.AvDwzo":3: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit? 

The correct way to reset MAILTO variable is to use empty quotes, like this:

MAILTO=''

Hope this helps.

In my case (and it seems to be OP's case as well), the issue was that I had a new line in the command to be executed, something like this

5 0 * * * some_command -some_param
-another_param

The overflowing line was of course interpreted as a new cron entry, and cron rightfully complained that the start of that line was not a valid minute identifier.

The following command fixed my problem with this issue

perl -pi -e 's|\r\n|\n|' /var/spool/cron/root

The problem was that Windows line separators (CRLF) were upsetting the Linux based cron. Changing the separators to be Linux line separators (LF) fixed the problem.

2

It can be an error while copy pasting from text editor. Everything should be in one line, e.g.:

Wrong:

source your-venv/basch/etc
python3 /yourhome/directory/manage.py

Correct:

source your-venv/basch/etc python3 /yourhome/directory/manage.py

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like