-   Linux - General (
-   -   VERY simple crontab question about mailing results (

Barefootpanda 02-05-2009 10:09 AM

VERY simple crontab question about mailing results
I don't know what it is, but I cannot think of a smooth way to do this...

I want to email the results of just one line of the crontab to an, but can't figure it out.

I want a 'du --max-depth=1' on a folder to run every Mon, Wed, Sat night at midnight and email the results.

I keep finding things for MAILTO=XXX, but won't that email EVERY cron event?

I'm sure this is simple and I just don't know how to ask google the right way. Thanks for any tips fellas.

colucix 02-05-2009 10:14 AM

What about giving explicit commands in the script itself?

/usr/sbin/sendmail "" << EOF
From: Me <>
To: Me <>
Subject: checking disk space
$(du --max-depth=1 /path/to/dir)

Barefootpanda 02-05-2009 10:15 AM

Great idea! I was obsessed with doing it in the cron, but this makes far more sense.

You are thinking that I would then run this script from the cron?

colucix 02-05-2009 10:19 AM


Originally Posted by Barefootpanda (Post 3433134)
You are thinking that I would then run this script from the cron?

Of course! I have some cron jobs which notify me when the job is done using this method. Just check the path of sendmail on your machine and modify it accordingly.

Barefootpanda 03-03-2009 10:45 AM

Sorry to revive a dead system, but I want to do this same thing, but this time I'm trying to use's a FreeNAS box and the community there is pretty quiet.

So I've tried just tweaking the script but it's not working at all. I am planning on just using the generic so I don't have to deal with authentication. I also really want to avoid using the system config file because FreeNAS uses it for all kinds of stuff.

I'm VERY unfamiliar with msmtp and don't even know if it's possible to give it a straight command w/o using a config file first. Thoughts?

All times are GMT -5. The time now is 09:00 PM.