Created a Cron job, now my inbox is getting flooded
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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?
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.
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!
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
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
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!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.