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.

Share:
10,916

Related videos on Youtube

William Orazi
Author by

William Orazi

When you're at the end of your rope, tie a knot and hang on.

Updated on September 18, 2022

Comments

  • William Orazi
    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
      Claudius over 11 years
      I have no problems adding this line to my user’s crontab using crontab -e on current Debian Wheezy.
  • Claudius
    Claudius over 11 years
    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.
  • Benny Hill
    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
    Claudius over 11 years
    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.
  • William Orazi
    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
    Claudius over 11 years
    /etc/crontab is not the file you edit with crontab -e. The file you edit with crontab -e is /var/spool/cron/crontabs/$(whoami).
  • Benny Hill
    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)