Cron ignoring an update to crontab

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?

3

2 Answers

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.

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like