0

CentOS 6.4 is happy with this, but CentOS 7 tells me "errors in crontab file, can't install.". What's wrong with this crontab file (just the 2 lines)?

0 0 * * * /home/web/backup-db.sh
0 1 * * * /home/web/backup-files.sh

I've tried this based on this answer here, this doesn't work either:

every '0 0 * * *' do /home/web/backup-db.sh
every '0 1 * * *' do /home/web/backup-files.sh

It's not permissions on those files, because this doesn't work either:

1 1 * * * /usr/sbin/ntpdate -s time-1.ncsu.edu

ntupdate is correctly installed, and in that location. So it's something about my crontab syntax I think - ideas?

  • 1
    Please explain what you did when trying to install the file (also the every .... from the answer you linked is valid only in the context of that ruby script, it's not valid syntax for a crontab. – Sven Aug 12 '17 at 18:01
  • If you open in the crontab in vim and do :set list are there any unexpected hidden characters, like carriage-returns? – shearn89 Aug 14 '17 at 10:09
  • @Sven - good to know that that middle block is ruby. The other blocks I've tried I've just installed by saving the file - ie.., 'crontab -e' to edit crontab, save. I'm using emacs to edit the file. – user2044774 Aug 14 '17 at 17:19
  • @shearn89, No unexpected hidden characters. – user2044774 Aug 14 '17 at 17:19
1

Adding a # on a single line at the end of the file fixed it. It was a premature EOF issue.

| improve this answer | |
0

If this is /etc/crontab, you're missing a username in there.

Try this:

0 0 * * * root /home/web/backup-db.sh
0 1 * * * root /home/web/backup-files.sh
| improve this answer | |
  • I tried that, didn't work. – user2044774 Aug 13 '17 at 1:10
0

I had the same error and adding # did not help. I just figure out that the error is because of my bad timing at each line. Be aware that there is five place to put time. I accidentally put 6 items!!

bad request:

1 0 * * * * /home/web/backup-db.sh

you should omit one * and the crontab will install and work fine.

correct:

 1 0 * * * /home/web/backup-db.sh

I just write this answer for others that may have the same problem!

| improve this answer | |
  • That was your typo, but not the error from the question. – RalfFriedl Jan 6 at 8:56

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.