Hello all
Just a short question in [1] is mentioned how to trigger a mail in case
* the job starts * the job finishes
what about
* the job print something to stdout like for CRON jobs (in the early days... ;))
Thanks a lot for answering Greetings Dr. Trigon
[1] https://wiki.toolserver.org/view/Job_scheduling#Receiving_mail_when_the_job_...
The output of tools which write direct-to-stdout should be sent to you by e-mail to your toolserver e-mail. If you set an adress to relay the mailings to, then you'll get cron jobs output there. Works for me, though.
Although, this ain't work from scratch for cronsubbed tools.
On Tue, Feb 8, 2011 at 6:06 PM, Dr. Trigon dr.trigon@surfeu.ch wrote:
Hello all
Just a short question in [1] is mentioned how to trigger a mail in case
- the job starts
- the job finishes
what about
- the job print something to stdout like for CRON jobs (in the early
days... ;))
Thanks a lot for answering Greetings Dr. Trigon
[1] https://wiki.toolserver.org/view/Job_scheduling#Receiving_mail_when_the_job_...
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
In article 4D516A08.5050503@surfeu.ch, Dr. Trigon dr.trigon@surfeu.ch wrote:
Just a short question in [1] is mentioned how to trigger a mail in case
- the job starts
- the job finishes
what about
- the job print something to stdout like for CRON jobs (in the early days... ;))
I don't think there's a built-in method of doing this. You could use a wrapper script that did something like:
#! /bin/ksh /path/to/mytool 2>&1 | mailx -s "Tool output" $LOGNAME
Or, if you only wanted to receive output on failure:
#! /bin/ksh f=$(mktemp) trap "rm -f $f" 0 /path/to/mytool >$f 2>&1 || <$f mailx -s "Tool output" $LOGNAME
Or only if the command generated output:
#! /bin/ksh f=$(mktemp) trap "rm -f $f" 0 /path/to/mytool >$f 2>&1 test -s $f && <$f mailx -s "Tool output" $LOGNAME
... etc.
I think you're the first person who's asked about this, but it seems like a useful feature, so I'll see if there's a way to make it easier.
- river.
On 02/09/2011 03:22 AM, River Tarnell wrote:
Or, if you only wanted to receive output on failure:
#! /bin/ksh f=$(mktemp) trap "rm -f $f" 0 /path/to/mytool>$f 2>&1 ||<$f mailx -s "Tool output" $LOGNAME
Just out of curiosity... is there a particular reason for the -f switch to rm here, or are you just trying to be extra sure the tempfile gets deleted?
I think you're the first person who's asked about this, but it seems like a useful feature, so I'll see if there's a way to make it easier.
I remember being disappointed by the lack of stderr output in the mail I got after switching my Commons MIME type statistics script over to SGE, but then I just thought "meh, I'm logging to a file anyway, I can always just look there if something goes wrong."
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
In article 4D529B28.7030703@vyznev.net, Ilmari Karonen nospam@vyznev.net wrote:
On 02/09/2011 03:22 AM, River Tarnell wrote:
Or, if you only wanted to receive output on failure:
#! /bin/ksh f=$(mktemp) trap "rm -f $f" 0 /path/to/mytool>$f 2>&1 ||<$f mailx -s "Tool output" $LOGNAME
Just out of curiosity... is there a particular reason for the -f switch to rm here, or are you just trying to be extra sure the tempfile gets deleted?
Because:
* Without -f, rm behaves differently depending on whether the script is run from an interactive terminal or not, so I always use -f to get consistent behaviour; and
* It doesn't matter if the file was already deleted, so I don't want an error message if rm fails.
- river.
Ilmari Karonen wrote:
I remember being disappointed by the lack of stderr output in the mail I got after switching my Commons MIME type statistics script over to SGE, but then I just thought "meh, I'm logging to a file anyway, I can always just look there if something goes wrong."
SGE has a parameter to send stdout and stderr merged.
First I have to thank you all very much for the numerous answers I got to this question!! Some remarks from my side:
Am 09.02.2011 22:47, schrieb Platonides:
Ilmari Karonen wrote:
I remember being disappointed by the lack of stderr output in the mail I got after switching my Commons MIME type statistics script over to SGE, but then I just thought "meh, I'm logging to a file anyway, I can always just look there if something goes wrong."
SGE has a parameter to send stdout and stderr merged.
@Ilmari Karonen: This is more or less what I'm doing, in fact I use the wikimedia mailing capabilities to send a mail to myself with any content (error messages, tracebacks, ...) I want. But I was wondering how SGE can replace such a common tool like CRON without havin same functionallity... :)
@Platonides: What is this parameter then??
Thanks and greetings DrTrigon
Am 09.02.2011 22:47, schrieb Platonides:
Ilmari Karonen wrote:
I remember being disappointed by the lack of stderr output in the mail I got after switching my Commons MIME type statistics script over to SGE, but then I just thought "meh, I'm logging to a file anyway, I can always just look there if something goes wrong."
SGE has a parameter to send stdout and stderr merged.
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
Dr. Trigon wrote:
@Platonides: What is this parameter then??
Thanks and greetings DrTrigon
It's -j
-j join
Declares if the standard error stream of the job will be merged with the standard output stream of the job. An option argument value of oe directs that the two streams will be merged, intermixed, as standard output. An option argument value of eo directs that the two streams will be merged, intermixed, as standard error.
If the join argument is n or the option is not specified, the two streams will be two separate files.
Note that you can pass the parameter to SGE inside the script, too.
On 02/13/2011 12:44 AM, Platonides wrote:
-j join
Declares if the standard error stream of the job will be merged with the standard output stream of the job. An option argument value of oe directs that the two streams will be merged, intermixed, as standard output. An option argument value of eo directs that the two streams will be merged, intermixed, as standard error.
If the join argument is n or the option is not specified, the two streams will be two separate files.
Note that you can pass the parameter to SGE inside the script, too.
Ah, yes, I'd seen that. In fact, I'm using it. What I don't recall seeing mentioned anywhere I looked was that things printed to stdout would be included in the job completion e-mail.
(In fact, even you didn't say so out right in your message, you just seemed to imply it. And I haven't tested it, so I'm not going to swear it's even true.)
In fact, the man page would seem to imply that it isn't:
If the -o option is not specified, the default file name for the standard output stream will be used. The default name has the following form: job_name.osequence_number where job_name is the name of the job, see -N option, and sequence_number is the job number assigned when the job is submitted.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
In article 4D56A4CD.6020807@surfeu.ch, Dr. Trigon dr.trigon@surfeu.ch wrote:
But I was wondering how SGE can replace such a common tool like CRON without havin same functionallity... :)
Well, SGE does not replace cron. SGE is an additional tool which is available to users; cron is not going away (indeed, cron is required to use SGE, except for one-shot jobs).
We would like all users to use SGE for their tools, which requires that everything which cron does on its own should *also* be possible, and easy, with SGE; otherwise users will not bother converting. However, this is an ongoing process and is obviously not complete.
- river.
Makes sense and means I should redirect output from 'cronsub' to stdout (or maybe stderr) to have 'cronie' make mail this to me... ;)
Greetings
Am 13.02.2011 01:33, schrieb River Tarnell:
In article 4D56A4CD.6020807@surfeu.ch, Dr. Trigon dr.trigon@surfeu.ch wrote:
But I was wondering how SGE can replace such a common tool like CRON without havin same functionallity... :)
Well, SGE does not replace cron. SGE is an additional tool which is available to users; cron is not going away (indeed, cron is required to use SGE, except for one-shot jobs).
We would like all users to use SGE for their tools, which requires that everything which cron does on its own should *also* be possible, and easy, with SGE; otherwise users will not bother converting. However, this is an ongoing process and is obviously not complete.
- river.
_______________________________________________ Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list: https://wiki.toolserver.org/view/Mailing_list_etiquette
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
In article 4D57E888.7040803@surfeu.ch, Dr. Trigon dr.trigon@surfeu.ch wrote:
Makes sense and means I should redirect output from 'cronsub' to stdout (or maybe stderr) to have 'cronie' make mail this to me... ;)
That won't do anything, because cronsub doesn't produce any output (except in case of an error); it submits the job to SGE, then exits. The job output is handled by SGE, which writes it to the configured output file.
- river.
Couldn't you just do `exec 2>&1` soon after the shebang line?
-Jeremy On Feb 9, 2011 4:44 PM, "Platonides" platonides@gmail.com wrote:
Ilmari Karonen wrote:
I remember being disappointed by the lack of stderr output in the mail I got after switching my Commons MIME type statistics script over to SGE, but then I just thought "meh, I'm logging to a file anyway, I can always just look there if something goes wrong."
SGE has a parameter to send stdout and stderr merged.
Toolserver-l mailing list (Toolserver-l@lists.wikimedia.org) https://lists.wikimedia.org/mailman/listinfo/toolserver-l Posting guidelines for this list:
On Wed, Feb 09, 2011 at 01:22:30AM +0000, River Tarnell wrote:
Or only if the command generated output:
#! /bin/ksh f=$(mktemp) trap "rm -f $f" 0 /path/to/mytool >$f 2>&1 test -s $f && <$f mailx -s "Tool output" $LOGNAME
If you only want to get mail when there is output, you can simply do:
/path/to/mytool | 2>&1 mail -e -s "Tool output" $LOGNAME
the -e will tell mail to suppress sending mail when stdin is empty.
Regards,
Andre
toolserver-l@lists.wikimedia.org