LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-24-2003, 08:31 AM   #1
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Rep: Reputation: 30
Created a Cron job, now my inbox is getting flooded


A few days ago I created a cron job in my /etc/crontab file. This was the only modification made to the file. Ever since then, I recieve about 20 emails per day that look as follows:
Quote:
To: root@myserver
From: Cron Daemon <root@myserver>
Subject: Cron <root@myserver> root nice -n 19 run-parts /etc/cron.daily

/bin/bash: root: command not found
/etc/crontab is as follows:
Quote:
[root@myserver root]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/

# run-parts
01 * * * * root nice -n 19 run-parts /etc/cron.hourly
02 4 * * * root nice -n 19 run-parts /etc/cron.daily
22 4 * * 0 root nice -n 19 run-parts /etc/cron.weekly
42 4 1 * * root nice -n 19 run-parts /etc/cron.monthly
# Local jobs
00 5 * * * /home/php/parse/my_script1
I would love to know what is cuasing this and how to make it stop. Any advice is appreciated.
 
Old 04-24-2003, 08:49 AM   #2
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
Any output (on STDERR or STDOUT) from a cronjob gets emailed to you. What happening is cron is trying to run a command call root which is then failing. How have you been editing your crontab? With crontab -e? Typically each user has a crontab rather than a single large crontab that lists the users. What do you get when you run crontab -l (thats an lower case L by the way) as root?

cheers

Jamie...
 
Old 04-24-2003, 08:16 PM   #3
Road
Member
 
Registered: Jan 2002
Distribution: Debian Based only but have tried most others.
Posts: 82

Rep: Reputation: 15
It sounds like you have an error in the script that runs at the bottom and the output is causing cron to send you an email (as stated above).

Check the script and if you need to just put the about put to /dev/null.
 
Old 04-25-2003, 06:04 AM   #4
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Original Poster
Rep: Reputation: 30
Quote:
[root@myserver logs]# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.10026 installed on Fri Apr 25 05:53:52 2003)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root nice -n 19 run-parts /etc/cron.hourly
02 4 * * * root nice -n 19 run-parts /etc/cron.daily
22 4 * * 0 root nice -n 19 run-parts /etc/cron.weekly
42 4 1 * * root nice -n 19 run-parts /etc/cron.monthly
# Local jobs
00 5 * * * /home/php/parse/my_script1
I manually edited /etc/crontab using vi to add the job. when I use crontab -e, it appears to give me the exact same file that is in /etc/crontab. AFAICT, my script works perfectly. I can execute the script just fine manually.
Quote:
It sounds like you have an error in the script that runs at the bottom and the output is causing cron to send you an email.
If this were the case, wouldn't the emails coming to me reference /home/php/parse/my_script1 rather than "root nice -19..."? And wouldn't they only come to me once a day rather than several time during the day? I'm not trying to shoot you down here because I genuinely do not know the answers to these questions.
 
Old 04-25-2003, 06:09 AM   #5
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
I recon you want to run crontab -e and remove just have 00 5 * * * /home/php/parse/my_script1 in your user specific crontab.

cheres

Jamie...
 
Old 04-25-2003, 08:31 AM   #6
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Original Poster
Rep: Reputation: 30
Quote:
I recon you want to run crontab -e and remove just have 00 5 * * * /home/php/parse/my_script1 in your user specific crontab.
Could you please clarify that a bit? Do I or don't I want anything but this line in crontab -e? This is a server that I am not logged into most of the time, so I want to make sure that it will still be run even if no users are logged in. Thanks for your help!
 
Old 04-25-2003, 08:46 AM   #7
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
crontab -e will allow you to edit the current user's crontab. This is typcially where you schedule things to run.

cheers

Jamie...
 
Old 04-25-2003, 09:00 AM   #8
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Original Poster
Rep: Reputation: 30
Quote:
I recon you want to run crontab -e and remove just have 00 5 * * * /home/php/parse/my_script1 in your user specific crontab.
Sorry, I meant the part above. Do I want to remove the my_script1 line from crontab -e or make that the only line in their?
 
Old 04-27-2003, 06:35 AM   #9
ritzlmayr
LQ Newbie
 
Registered: Apr 2003
Location: Austria
Distribution: RedHat
Posts: 17

Rep: Reputation: 0
Since you edited the system crontab wich is /etc/crontab
instead of
00 5 * * * /home/php/parse/my_script1
it should be
00 5 * * * root /home/php/parse/my_script1
 
Old 04-27-2003, 07:00 AM   #10
pablob
Member
 
Registered: Apr 2003
Location: Madrid
Distribution: RHEL, Kubuntu, Solaris, TRU64
Posts: 382

Rep: Reputation: 31
Oh, man, from:

"/bin/bash: root: command not found"

it really seems clear that you should erase the term 'root' inside the crontab:

01 * * * * root nice -n 19 run-parts /etc/cron.hourly

Cron is trying to execute a command named "root", which of course, doesn't exist. Try:

01 * * * * nice -n 19 run-parts /etc/cron.hourly


- On another matter of things, the execution of cron jobs always mails the user with the results, wherever it ends in success or not.
If you want it disabled, you have to define a environment variable MAILTO and leave it empty.

The easiest will be to add a line like this at the end of /etc/profile, or /root/.bashrc

MAILTO=""; export MAILTO
 
Old 04-27-2003, 07:19 AM   #11
ritzlmayr
LQ Newbie
 
Registered: Apr 2003
Location: Austria
Distribution: RedHat
Posts: 17

Rep: Reputation: 0
pablob:
TruckStuff has modified the system crontab! The correct syntax is to include the username (wich is ususally root) in each line. Your post applies to a user crontab!
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job wbatzle Linux - Newbie 2 07-12-2005 04:19 PM
cron job the_rhino Linux - Newbie 10 10-02-2004 03:34 PM
cron job ? johnyy Linux - Software 3 12-10-2003 06:00 PM
Cron Job imanahmadi Linux - Newbie 1 07-03-2003 11:39 PM
Cron job T-Rex Linux - Newbie 1 09-26-2001 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:42 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration