You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Question

After the run of a job chain, the order log should be sent as an attachment of an email instead to receive a mail per job that has been executed during the job chain.

Answer

You can achieve this by adding a step with an sendEmail-Job at the end of the job chain. See the example below.

How it works

The JITL-Job JobSchedulerManagedMailJob is used to send the email. The parameter attachment will be set by the post processing script. The postprocessing set the name of file using the api method spooler.log_dir, the order_id and the job chain name provided by the order object. The name of the order log has the format $log_dir/order.<job_chain_path>.<order_id>.log where the job chain path have , instead of /.

 

Example shell script exit function
<job title="Send Mails" order="yes" stop_on_error="no" name="SendMail">
 <description >
 <include file="jobs/JobSchedulerManagedMailJob.xml"/>
 </description>

 <params >
 <param name="to" value="info@sos-berlin.com"/>

 <param name="subject" value="order log"/>
 </params>

 <script language="java" java_class="sos.scheduler.managed.JobSchedulerManagedMailJob"/>

 <monitor name="Prozess1" ordering="1">
 <script language="java:javascript">
 <![CDATA[
function spooler_process_before(){
 
 var order = spooler_task.order;
 var job_chain = order.job_chain.path;
 job_chain = job_chain.substring(1);
 job_chain = job_chain.replace(/\//g,",");

 var f = spooler.log_dir + "/order." + job_chain + "." + order.id + ".log";

 spooler_log.info(f);
 order.params.set_var("attachment",f);
 
 return true;
}
 ]]>
 </script>
 </monitor>

 <run_time />
</job>

 

 

  • No labels