Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Trying to set up a cronjob:

0 12 * * * /usr/bin/mysqldump --all-databases > /backups/mysql/`date "+%Y-%m-%d"`.sql

Getting error:

crontab: installing new crontab
"/tmp/crontab.fuly8s":2: bad day-of-month
errors in crontab file, can't install.
Do you want to retry the same edit?

I'm not sure where the error is, any suggestions?

share|improve this question
    
I have no problems adding this line to my user’s crontab using crontab -e on current Debian Wheezy. –  Claudius Dec 3 '12 at 15:53
add comment

migrated from stackoverflow.com Dec 3 '12 at 15:38

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 1 down vote accepted

The error complains about line 2 of your crontab. In order to decide what the error is, we need to see this line, and preferably the complete crontab as shown in the editor.

Most likely, you removed a # somewhere which now causes a previous comment to be regarded as a cronjob specification.

share|improve this answer
add comment

If you're adding a line to crontab you need a user field. For instance:

0 12 * * * root /usr/bin/mysqldump --all-databases > /backups/mysql/`date "+%Y-%m-%d"`.sql

Does that fix the problem?

share|improve this answer
    
If the OP uses a user-specific crontab (usually edited using crontab -e), he must not use a user field. The fact that the crontab is installed hints at a user-specific one rather than /etc/crontab. –  Claudius Dec 3 '12 at 15:50
    
@Claudius - Yep. The question doesn't specify how he's adding the cron job though (and it looks fine for a user-specific crontab) so I am assuming he's just editing /etc/crontab. –  Benny Hill Dec 3 '12 at 15:56
    
But how would he edit /etc/crontab in a way that these messages are displayed? To my knowledge, changes to /etc/crontab take effect immediately and editing it does not occur via some temporary file in /tmp. –  Claudius Dec 3 '12 at 15:58
    
Looks like it shoulud be alright...sorry I didn't provide more info earlier. It was edited from crontab -e....It accepted the new crontab now. I'll just have to wait and see if it executes properly today. Thanks for the help. –  pennstate_fanboy Dec 3 '12 at 16:39
    
@Claudius - it saves crontab to /tmp first to ensure the syntax is correct and there are no errors before replacing the file to the best of my knowledge. –  pennstate_fanboy Dec 3 '12 at 16:40
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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