LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 12-03-2006, 04:33 PM   #1
pridefc
Member
 
Registered: Nov 2005
Distribution: redhat, debian, ubuntu
Posts: 47

Rep: Reputation: 15
/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.
 
Old 12-03-2006, 04:56 PM   #2
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
How did you edit crontab? (i.e. vi, emacs, gedit, crontab -e ... ?)
Quote:
[snip]it was thinking that "root" was the command and was trying to run it.
Indeed. From the cron man page:
Code:
The sixth field of a line in a crontab file is a string that
     is  executed  by the shell at the specified times.
... if you want it executed with root privaledges, then it should be in the root user's crontab.

So the next question is: are you sure you edited the right one?
 
Old 12-03-2006, 04:57 PM   #3
mikemrh9
Member
 
Registered: Nov 2003
Distribution: Arch
Posts: 136

Rep: Reputation: 21
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.
 
Old 12-03-2006, 06:57 PM   #4
Simon Bridge
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
Quote:
Originally Posted by mikemrh9
the name 'root' should be in the /etc/crontab
<slaps forehead> Of course! This is the systemwide crontab file and I'm an idiot Yeah - unlike the regular crontab, the system wide one has a "user" feild.
 
Old 12-05-2006, 11:00 PM   #5
pridefc
Member
 
Registered: Nov 2005
Distribution: redhat, debian, ubuntu
Posts: 47

Original Poster
Rep: Reputation: 15
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...
 
Old 12-12-2006, 07:09 PM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,248

Rep: Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025Reputation: 2025
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
(bash) echo "#!/bin/bash" event not found - trying to generate profiles automatically jimieee Programming 9 05-03-2006 10:24 AM
Error when starting up snort: bash:!/bin/sh/usr/local/bin/snort :Eent not found cynthia_thomas Linux - Software 1 11-11-2005 02:59 PM
root@localhost:~# xf86config -bash: xf86config: command not found klemen Slackware 17 01-06-2005 02:56 AM
No root device found; exiting to /bin/sh Indian_bee Linux - Software 6 07-09-2004 05:20 AM


All times are GMT -5. The time now is 05:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration