LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Created a Cron job, now my inbox is getting flooded (https://www.linuxquestions.org/questions/linux-general-1/created-a-cron-job-now-my-inbox-is-getting-flooded-56560/)

TruckStuff 04-24-2003 08:31 AM

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.

jharris 04-24-2003 08:49 AM

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...

Road 04-24-2003 08:16 PM

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.

TruckStuff 04-25-2003 06:04 AM

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. :)

jharris 04-25-2003 06:09 AM

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...

TruckStuff 04-25-2003 08:31 AM

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!

jharris 04-25-2003 08:46 AM

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

cheers

Jamie...

TruckStuff 04-25-2003 09:00 AM

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?

ritzlmayr 04-27-2003 06:35 AM

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

pablob 04-27-2003 07:00 AM

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

ritzlmayr 04-27-2003 07:19 AM

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!


All times are GMT -5. The time now is 02:17 PM.