Koozali.org: home of the SME Server

Crontab hassle

Alex Schaft

Crontab hassle
« on: July 04, 2001, 07:37:15 PM »
Hi,

I've added some entries into my /etc/crontab to run fetchnews for leafnode. Now I keep getting messages like

Subject cron root /etc/startmail

Text /bin/bash: root: command not found

and

Subject Cron root run-parts /etc/cron.hourly
Text /bin/bash: root: command not found

Below is a copy of my crontab. Can anybody tell me what's wrong?

#------------------------------------------------------------
# DO NOT MODIFY THIS FILE! It is updated automatically by the
# e-smith server and gateway software. Instead, modify the source
# template in the /etc/e-smith/templates directory. For more
# information, see http://www.e-smith.org.
#
# copyright (C) 1999, 2000 e-smith, inc.
#------------------------------------------------------------

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# run-parts

01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

# fetchmail times during office hours

*/30    8-17    *       *       1-5     root    /etc/startmail

# fetchmail times outside office hours

0       0-7/2   *       *       1-5     root    /etc/startmail
0       18-23/2 *       *       1-5     root    /etc/startmail

# fetchmail times during the weekend

# none

# fetchnews times during office hours

*/30    8-17    *       *       1-5     root    /usr/sbin/fetchnews

# fetchnews times outside office hours

0       0-7/2   *       *       1-5     root    /usr/sbin/fetchnews
0       18-23/2 *       *       1-5     root    /usr/sbin/fetchnews

# fetchnews times during the weekend

# none

#------------------------------------------------------------
# TEMPLATE END
#------------------------------------------------------------

Inq

Crontab hassle
« Reply #1 on: February 17, 2005, 12:07:57 PM »
I have this trouble now also, all I did was add custome-template and suddenly I get these emails saying

/bin/bash: root: Command not found ???

Maybe someone has a clue

Offline WongDai

  • 4
  • +0/-0
    • http://wongdai.infosecwest.com
Crontab hassle
« Reply #2 on: February 18, 2005, 08:08:17 AM »
It's been a while since I did any serious Linux, but the format of the crontab is like this (I think):

each line consisting of 6 fields separated by spaces

Fields
  minute of the hour, 00 to 59
  hour of the day, 00 to 32 (military time)
  day of the month, 1 to 31
  month of the year, 1 to 12
  day of the week, sun, mon, tue,....
  actual command to execute


So basically, it is taking your "root" and expecting it to be a command, which it isn't.

i.e. delete the word "root" and see how you go.

Regards

WongDai
Disarm the dynamite!...

Offline jonroberts

  • ****
  • 111
  • +0/-0
    • http://www.westcountrybusiness.com
Crontab hassle
« Reply #3 on: June 27, 2006, 12:12:51 PM »
I realise this is an old post, but I've just had the same problem & found the solution, so thought I'd post it here just in case its of use anyone else.

In my case I knew the problem was of my own making.  In my 'attempts to expand my field of knowledge' (or general messing about), I was playing with the Crontab command and issued the command crontab /etc/crontab while logged on as root.  I then got /bin/bash: root: Command not found errors every time cron ran.

I found the solution here - http://kuchinglug.blogspot.com/2006/03/about-cron-and-annoying-binbash-root.html

The main information is as follows:

Now, usually you'll use the command crontab -e to edit your own tasks. But if you happen to edit the /etc/crontab file manually, DO NOT run the command crontab /etc/crontab!! This will cause cron to take /etc/crontab as a user crontab and thus expecting field 6 (the field straight after the first 5 time specification fields) to be the command to execute.

So boys and gals, if that happens:

1. backup your system wide crontab file (/etc/crontab)
2. run crontab -r as root, to flush all the cron jobs
3. check if the system wide crontab is still in good health, if it is leave it be
4. restore the system wide crontab file if necessary
5. cron will read and execute the system wide cron tasks accordingly next time it wakes up

I also restarted crond, but I don't think it was necessary.  Anyway, it solved my problem.

Hope that may help in the (unlikely) event that there is anyone else out there as dopey as me.
......

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Crontab hassle
« Reply #4 on: June 27, 2006, 06:48:39 PM »
Quote from: "jonroberts"

Hope that may help in the (unlikely) event that there is anyone else out there as dopey as me.


That's an overly complicated solution, though. WongDai's advice to edit out 'root' from the custom template is correct, and simpler, advice. Follow by:

/sbin/e-smith/expand-template /etc/crontab