Re: [gentoo-user] Another question on mailing cron-job output

2005-07-02 Thread James Hiscock
 Is there any way to *not* receive mail from specific cron jobs, while
 leaving the rest of the mails intact? I looked at man cron and man
 crontab, but they seemed to indicate that it's kind of an all-or-nothing
 deal.

It's not an all-or-nothing deal, depending on how you create the cron
job: instead of adding a script to
/etc/cron.{hourly,daily,weekly,monthly} (where it _is_ an
all-or-nothing deal, because of the /etc/crontab entry that runs the
jobs), just add it to /etc/crontab, and redirect the output to
/dev/null for the jobs you don't want the output for, as was already
suggested.

...or, if you want the job to be run by a specific user, use crontab
-e to create a job schedule for a given user.

 What I'd *really* like is the output from the jobs that I've set to mail
 me output, and a summary of names of any other jobs that ran
 successfully, just so I know that they ran successfully. 

For this, you can do something like:

* * * * * echo somescriptsomewhere  /some/script/somewhere

That'd get you the name of the script (anything after echo) and all of
the output of /some/script/somewhere... and the way I've written that
crontab entry, the script would be run every minute of every day,
which probably isn't what you want. See man 5 crontab for info on
the file format. There's no need for a mail -s command in there at
all...

(one other suggestion, although I'm not sure it's going to be useful
for ya: you might want to add -q to your esync cron job [on the
update-eix part], so you don't get that annoying output at the end
when it's updating the cache... of course, that'll kill any output
from update-eix, so I'm not entirely sure how much that'll help...)

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Another question on mailing cron-job output

2005-06-29 Thread Myk Taylor
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

This sounds perfectly reasonable.  cron mails you and output the command
sends to stdout, so yes, redirecting its output to a file would also
prevent cron's email.  the crontab lines would look something like:

0 * * * * command  /dev/null  echo commandTitle  done_deals.txt
1 3 * * * cat done_deals.txt  rm done_deals.txt

man bash for more info on commandline syntax.  you could get even
sneakier with an 'if' statement (or a combination of  and ||),
outputting different messages for success and failure of the cron job.

compiling successful jobs into a list can be useful, but the
modifications to cron to get it done are pretty minimal--I doubt there's
much call for an external tool in this case.  the default behavior for
cron accomplishes something functionally equivalent anyway: it informs
you by mail if a job fails.  So you'd still know (by process of
elimination) which jobs succeeded and which failed.

- --myk

Holly Bostick wrote:
 If I:
 
 Changed the individual job that I don't want mailed, but want
 notification of to send it's output to /dev/null (is it only /dev/null,
 or will cron still mail me if I output to a text file instead?) *and
 then to* echo the name of the job to (let's say) done_deals.txt after
 the job completed, and then
 
 Made a new cron job that runs last in that time period which sent me the
 output of cat done_deals.txt (which would hopefully contain the names of
 all the jobs that completed, but whose actual output was sent to
 /dev/null or whatever)
 
 would that work?
 
 It sounds reasonable, although I don't know how to do it (I am so not a
 command-line jockey), and it also sounds easily repeatable (for cron
 jobs of all time periods, or if new jobs are added to any time period),
 which supports it being doable.
 
 Does this sound flakey? Does this sound useful? And if it does sound
 useful, is there any tool that would allow me to create a more global
 setup in case I wanted to provide this solution to others (i.e. post it
 on the forums as some kind of script, or package it in some way for
 Bugzilla)?
 
 Holly
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCwsrxBOPsJyAQkeARArh+AKCyPhrkqNFdQV4RovfmzBzmjjdr8wCfS6W6
cM+/Ji3FIVOMXNb/djN787g=
=SlBP
-END PGP SIGNATURE-
-- 
gentoo-user@gentoo.org mailing list