Error setting up Crontab
10,916
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.
Related videos on Youtube
Author by
William Orazi
When you're at the end of your rope, tie a knot and hang on.
Updated on September 18, 2022Comments
-
William Orazi over 1 year
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?
-
Claudius over 11 yearsI have no problems adding this line to my user’s crontab using
crontab -e
on current Debian Wheezy.
-
-
Claudius over 11 yearsIf the OP uses a user-specific crontab (usually edited using
crontab -e
), he must not use a user field. The fact that the crontab isinstalled
hints at a user-specific one rather than/etc/crontab
. -
Benny Hill over 11 years@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.
-
Claudius over 11 yearsBut 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
. -
William Orazi over 11 years@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. -
Claudius over 11 years
/etc/crontab
is not the file you edit withcrontab -e
. The file you edit withcrontab -e
is/var/spool/cron/crontabs/$(whoami)
. -
Benny Hill over 11 years@pennstate_fanboy - Claudius is absolutely correct and deserves the reputation for this question. (I'm +1-ing your answer Claudius)