/bin/bash: root: command not found
Hello,
I edited /etc/crontab directly and added 00 10 * * * root /bin/script.sh Since then, I get "/bin/bash: root: comand not found" but the command runs fine. So I removed the "root" from the line since it was thinking that "root" was the command and was trying to run it. 00 10 * * * /bin/script.sh then restarted crond "/etc/init.d/crond restart" so that it would re-read the modified /etc/crontab. However, I still get "/bin/bash: root: command not found" although I removed the "root" from the line. It must not be reading the new /etc/crontab file. Is there a way to make it read the modified crontab? I must be doing something wrong. Thanks. |
How did you edit crontab? (i.e. vi, emacs, gedit, crontab -e ... ?)
Quote:
Code:
The sixth field of a line in a crontab file is a string that So the next question is: are you sure you edited the right one? |
I think that you were right the first time - the name 'root' should be in the /etc/crontab file.
The problem could be the syntax for the time for the command to run. I assume that you want it to run at 10:00 each day, and not on the 10th of the month? Try putting 0 instead of 00 for the first digit. The format should be based on the following: minute 0-59 hour 0-23 day of month 1-31 month 1-12 (or names, see below) day of week 0-7 (0 or 7 is Sun, or use names) ie try putting: 0 10 * * * root /bin/script.sh If you have 00 for the minute field, that could possibly be interpreted as 0 0 10 * * for the time, making 'root' the first command, hence the 'command not found' message. |
Quote:
|
Thanks guys.
But if you have one in /etc/crontab and one in crontab -l, which one takes effect if they're different or the same? Does /etc/crontab stay dormant until you load it? It seems it's running both of them, the one in /etc/crontab and the one that shows up when you do crontab -l. Kind of confusing... |
It runs both.
The system is that /etc/crontab is (usually) for admin tasks eg backup and the user's individual crontabs are for their own progs (whatever). ALL crontabs will be processed by the cron daemon, so do not duplicate instructions across these files. Incidentally, cron re-reads crontab files every minute, so restart is not needed unless cron dies/hangs (very rare). It also triggers a re-read if you use crontab -e (dedicated crontab editor) instead of eg vim. crontab -e is really for non-root users, they are not supposed to edit their files directly. |
All times are GMT -5. The time now is 12:34 PM. |