10

I get the following error in my syslog:

Oct 17 13:14:03 tracker cron[873]: (*system*) ERROR (Syntax error, this crontab file will be ignored)
Oct 17 13:14:03 tracker cron[873]: Error: bad minute; while reading /etc/crontab

I don't see any bad minutes though! My crontab file is:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 18   * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 18   * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 18   1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
1
  • 2
    Which operating system and version? Older Unix systems might not support the syntax for setting environment variables. Oct 17, 2011 at 15:09

6 Answers 6

11

Use cat -v /etc/crontab to check for unintended control characters.

2

Cron tab requires at least the first and last lines of the file not to be actual cron instructions. You can put comments instead - such as those below in a file:

# START CRON JOB LIST
* * * * * /path/to/script/script1.sh
0 3 * * 0 /path/to/script/script2.sh
5 0 * * 1 /path/to/script/script3.sh
# END CRON JOB LIST

Install it like so

sudo crontab -u user /path/to/cron/file

This should work for you.

1
  • I add comment and first and last line so it work Jul 22, 2021 at 3:17
2

I have faced a similar issue with this error:

crontab: installing new crontab
"/tmp/crontab.MswKCq":0: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit? n
crontab: edits left in /tmp/crontab.MswKCq

Googled all round and found that this was the error due to the no space in log folder for cron i.e in /var. Make sure to run df -h /var/ and see if there is enough space there.

2
  • Seriously?  A problem with disk free space can cause an error message that says that there’s a syntax error in an existing, static input file?  Can you provide any evidence (e.g., a reference) that other people have observed this bug? May 25, 2020 at 21:23
  • yes, the bad minute error can occur while updating the crontab due to the disk space. I have updated the post with the details. May 27, 2020 at 14:04
1

I have same error on Ubuntu 16.04. Problem have with empty assignment to MAILTO

MAILTO=

The problem I found with the help of chkcrontab

0

For anyone having issues on a Mac you can check your crontab for non-printing characters by typing

crontab -l | cat -e

or

sudo crontab -l | cat -e

if you have a root crontab.

2
  • The question doesn't mention a Mac.
    – RalfFriedl
    Jun 25, 2019 at 20:30
  • 4
    Indeed it does not, but the question doesn't specifically indicate linux either. I don't see why you wouldn't want to cover how to do this on as many operating systems as possible. Jun 25, 2019 at 20:36
0

solution is very simple but hidden mate.

goto

/var/spool/cron/crontabs/root

edit your crontab file via notepad++ then press CTRL+F then goto Replace tab.

then write in. Find with \r Replace with (this input should empty make sure no space etc)

then click replace all button. There you go mate you issue resolve ;)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.