Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

    
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
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

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. – wiliam.orazi 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. – wiliam.orazi Dec 3 '12 at 16:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .