help: using cron + my bash script --> don't want mail from script
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.
help: using cron + my bash script --> don't want mail from script
good morning folks,
I wrote a bash script which logs into our database and generates a neato report telling me a daily breakdown of transactions per device. I launch it every morning automagically using cron (crontab -e .... enter all the parameters....). That part works just lovely.
The report output is sent to an output file (daily_report_${inputdate}.txt). The database connection/disconnection messages are all sent to my user's mail account.
Is there a way that I can NOT have any of those boring old messages sent to my mail account cause I'd rather not have to clean up garbage mail...?
I'm curious if "...myscript 2>&1 >/dev/null" would interfere with my actual report. Inside the functions I take that line of output and redirect it to my output file: >> $outfile. Would sending sterr + stout to the great void also take my report into |-|3||? I'll test it here shortly and report.
I also like the MAILTO="" idea.
Currently my crontab looks like this:
33 09 * * * bash /home/myuser/number_trans_daily
Does this look right?
MAILTO=""
...(other entries)...
33 09 * * * bash /home/myuser/number_trans_daily
Last edited by beeblequix; 11-23-2007 at 09:07 AM.
i wouldn't recommend changing MAILTO personally, as it's only *THIS* script you want to silent, not everything in cron.
I agree. Sorry but I did not think about other crontab entries, I was just focused on the single one. Indeed, redirection of stdout and stderr to /dev/null is far better. Thanks for taking notice!
A better idea might be just to redirect std_out to /dev/null and leave std_err alone. This way you will only get mail if some error occurs in your cronjob.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.