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.

I've commented out a line in the crontab on a debian server, which I guess was there by default yet was causing me to get error emails every hour:

# m h dom mon dow user  command
17 *   * * *   root    cd / && run-parts --report /etc/cron.hourly

However, the error emails keep coming in as if it hasn't been commented out. The error emails:

Subject: Cron <root@(none)> root    cd / && run-parts --report /etc/cron.hourly (failed)
/bin/sh: root: not found

Any ideas?

share|improve this question
    
wouldn't be easier to sudo vi crontab, that way you are modifying root's crontab? –  Patrick Feb 19 '11 at 14:16
    
@patrick: I'm logging in as root, so there's no sudo.. –  GJ. Feb 19 '11 at 18:24
add comment

2 Answers

up vote 3 down vote accepted

When you say "the crontab" you're not being specific. You should say which one you mean. However, based on the contents, it looks like /etc/crontab. Since that file does have a user field, it doesn't make sense that you'd get that error. My bet is that there's a user crontab that has that line in it. User crontabs don't contain user fields.

The proper thing to do is not to change that line in /etc/crontab. There may be other jobs it runs.

You can edit that file and the files in the /etc/cron.* subdirectories using any editor. You can specify the editor you want to use when you use crontab -e by setting the EDITOR environment variable.

You should use crontab -e to edit user crontabs (including root's). Remove the user field or remove that line in the user crontab where it appears (not /etc/crontab). User crontabs don't have a user field, but the system crontabs do.

User crontabs are located in /var/spool/cron/crontabs. You can sudo grep for the line to find out which file has the stray line. Again, only use crontab -u username -e to edit the user crontab.

share|improve this answer
add comment

Check the manpage on your system for crontab(5) (man 5 crontab), especially under the "EXAMPLE SYSTEM CRON FILE" section. Only the /etc/crontab file includes a username field. Non-system user crontabs do not include this field. If you want to edit /etc/crontab, then use a text editor, not the crontab(1) command.

share|improve this answer
add comment

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.