Re: [gentoo-user] Another question on mailing cron-job output
> 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
-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
Re: [gentoo-user] Another question on mailing cron-job output
[EMAIL PROTECTED] schreef: > hello, > > On Wed, Jun 29, 2005 at 03:42:08PM +0200, Holly Bostick wrote: > >>Hey, list, > > > >>Alternatively, since the output cron jobs are being mailed via a mail -s >>command in the scripts themselves, can I/should I just put a dummy user >>in cron's 'normal' mailto slot, so that the "other" mail essentially >>goes to /dev/null? >> >>It's not a big problem now, but I can see how, as I learn more about >>cron and add more jobs for the daemon to run, it could get to be. >> >>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. But I don't >>think cron does that... does it? >> > > the only thing i know is to put all the output of the cronjob you won't > have an email to /dev/null > for example: > 3 4 * * * /usr/bin/ls /tmp > /dev/null > > because auf cron only send's emails when it gets output you will never > get an email anymore. Oh, thanks, now I've learned something -- cron only emails when it gets output. I suppose that makes perfect sense when you think about it, but being new to this, I didn't really know how to think about it in the first place :-) . > > But as you ask for an notification i don't know just one way. > do the task in an extra script an filter there the output, so that the > cron daemon only gets the output u wan't to have emailed. > that's why programs often have the -q --quiet option which only prints > errors. Thanks again... this gives me an idea. One that I don't know how to implement, of course, but that seems like it ought to be doable with the tools I already know of (but don't know how to use properly). But maybe someone who does can tell me if I'm nuts or not. 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 > > > >>Thanks for any help, > > hope i could help a little bit > > >>Holly > > > cya > > alex > > >>-- >>gentoo-user@gentoo.org mailing list -- gentoo-user@gentoo.org mailing list
Re: [gentoo-user] Another question on mailing cron-job output
hello, On Wed, Jun 29, 2005 at 03:42:08PM +0200, Holly Bostick wrote: > Hey, list, > Alternatively, since the output cron jobs are being mailed via a mail -s > command in the scripts themselves, can I/should I just put a dummy user > in cron's 'normal' mailto slot, so that the "other" mail essentially > goes to /dev/null? > > It's not a big problem now, but I can see how, as I learn more about > cron and add more jobs for the daemon to run, it could get to be. > > 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. But I don't > think cron does that... does it? > the only thing i know is to put all the output of the cronjob you won't have an email to /dev/null for example: 3 4 * * * /usr/bin/ls /tmp > /dev/null because auf cron only send's emails when it gets output you will never get an email anymore. But as you ask for an notification i don't know just one way. do the task in an extra script an filter there the output, so that the cron daemon only gets the output u wan't to have emailed. that's why programs often have the -q --quiet option which only prints errors. > Thanks for any help, hope i could help a little bit > Holly cya alex > -- > gentoo-user@gentoo.org mailing list -- gentoo-user@gentoo.org mailing list
[gentoo-user] Another question on mailing cron-job output
Hey, list, You may remember me asking previously about how to get cron to mail me the output of esync, which is working fine so fine, in fact, that I think I'll take Neil's recent suggestion of putting revdep-rebuild -p in cron.weekly and having that output mailed to me as well. So atm, my cron jobs mail me the output of esync and glsa-check (and shortly revdep-rebuild -p). But there's also a default cron job that runs daily... test -x /usr/sbin/run-crons && /usr/sbin/run-crons Now, I want this job to run, but I really don't need the input mailed to me, especially if this is what it is (and this *is* what it is): > !!! aux_get(): ebuild path for 'app-misc/FileRunner-2.5.1' not specified: > !!!None > Building database from scratch .. > Reading Portage settings .. > Using eix database in /var/cache/eix > Using portage cache: /usr/portage/ > Reading cache for main tree: > 0%000%001%002%002%003%004%005%005%006%007%008%008%009%010%010%011%012%013%013%014%015%016%016%017%018%018%019%020%021%021%022%023%024%024%025%026%027%027%028%029%029%030%031%032%032%033%034%035%035%036%037%037%038%039%040%040%041%042%043%043%044%045%045%046%047%048%048%049%050%051%051%052%053%054%054%055%056%056%057%058%059%059%060%061%062%062%063%064%064%065%066%067%067%068%069%070%070%071%072%072%073%074%075%075%076%077%078%078%079%080%081%081%082%083%083%084%085%086%086% 087%0 > Reading overlays .. > /usr/local/portage/ > 0%000%001%002%002%003%004%005%005%006%007%008%008%009%010%010%011%012%013%013%014%015%016%016%017%018%018%019%020%021%021%022%023%024%024%025%026%027%027%028%029%029%030%031%032%032%033%034%035%035%036%037%037%038%039%040%040%041%042%043%043%044%045%045%046%047%048%048%049%050%051%051%052%053%054%054%055%056%056%057%058%059%059%060%061%062%062%063%064%064%065%066%067%067%068%069%070%070%071%072%072%073%074%075%075%076%077%078%078%079%080%081%081%082%083%083%084%085%086%086%087% 088%08 > /usr/local/bmg-main/ > 0%000%001%002%002%003%004%005%005%006%007%008%008%009%010%010%011%012%013%013%014%015%016%016%017%018%018%019%020%021%021%022%023%024%024%025%026%027%027%028%029%029%030%031%032%032%033%034%035%035%036%037%037%038%039%040%040%041%042%043%043%044%045%045%046%047%048%048%049%050%051%051%052%053%054%054%055%056%056%057%058%059%059%060%061%062%062%063%064%064%065%066%067%067%068%069%070%070%071%072%072%073%074%075%075%076%077%078%078%079%080%081%081%082%083%083%084%085%086%086%087% 088%0 > Applying masks .. > Database contains 9542 packages in 137 categories. Woo-hoo. The only error in this I know about (just haven't fixed it yet, but since it's why I can't even install the program, I know that particular ebuild is broken), and the rest of the output is pretty non-informative/useless. 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. Alternatively, since the output cron jobs are being mailed via a mail -s command in the scripts themselves, can I/should I just put a dummy user in cron's 'normal' mailto slot, so that the "other" mail essentially goes to /dev/null? It's not a big problem now, but I can see how, as I learn more about cron and add more jobs for the daemon to run, it could get to be. 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. But I don