[Discuss] cron and MAILTO [Resolved...kind of..]

pw p.willis at telus.net
Fri Feb 22 13:18:52 PST 2008


pw wrote:
> Lionel Widdifield wrote:
>> On Thu, Feb 21, 2008 at 12:58:53PM -0800, pw wrote:
>>> Any other options, short of creating a new user for each set of
>>> cron jobs?
>>
>> Does an alias count.
>>
> 
> 
> I was hoping to send only parts of the crontab
> output to various users.
> 
> An alias has no login, hence no crontab (??) for that user.
> So, that doesn't provide multiple crontabs to work with.
> 


I thought better of MAILTO in crontab in favour of
associating the mail alert for each process with the process
itself. It also allows me to manage the process output emails
using a database instead of editing crontab or
the script when people change what they are doing.


ie:

#!/bin/sh
#just have crontab use this shell script
#to run the process and collect the log output
#into a temp file

EMAIL=`psql -t -d sysstuff -U bluto -c "SELECT email FROM process_adm 
WHERE process ilike 'process one'"`


#PROCESS ONE

cat /dev/null > /tmp/proc1.log

DS=`date`
SUBJECT="PROCESS ONE LOG $DS"

echo "PROCESS ONE STARTS: $DS" >> /tmp/proc1.log

[...do work here] >> /tmp/proc1.log

DS=`date`

echo "PROCESS ONE FINISHES: $DS" >> /tmp/proc1.log

#mail the log file to the person responsible

cat /tmp/proc1.log | mail -s "$SUBJECT" $EMAIL





More information about the Discuss mailing list