Subsections

Scripts

Sched includes the possibility of excuting Perl scripts at some point of job execution.

You can use result to other task with macro. (ok, err, finish and the hash %result). Job variables are usable in scripts and are replaced before execution.

Script are executed in perl Safe environment. Access is restricted to functions defined in the Script and Cond modules.

Example

 ok('id1')
 $result{'id1'}
 mailto('${EMAIL}', '${SUBJECT}', 'message') ;
 max_start_time('+3 hours') ; # 3 hours from the job start
 max_start_time('23:00') ; # now < today 23:00

 open(FP, '>/tmp/test') ;  # impossible


Management of the conditions on a task

The cond field of task and job element is a perl expression evaluated before task execution and at the end of job.

If the condition failed (return undef or also 0), the command will not be executed. If other task are not ended, the condition will be frozen and will be execute when all task where completed.

Figure 9: Condition editor with sched_builder
\includegraphics{inc/cond.eps}

After command script

The field after_cmd of the task is a Perl expression interpreted after the execution of the task. The result of this expression is placed in the after_cmd_status field

If all the dependent tasks are not finished, script fails without being execute.

Example

  ok('${ID}') or mailto('root', 
                        'Error on task ${ID}',
                        'This task was ..') ;

Notice

In this example variable ID will be replaced before the execution.

Available Macros

Macro Information Example
ok('task_id') Return true if task_id have an exit code equal to 0. ok('test1')
err('task_id') Return true if task_id have an exit code different of 0. ok('id1') && err('id2')
finish('id') Return true if id is finished. finish('id2')
job_end([status [,info]]) Send a TERM signal to the job. job_end(1) if err('id1')
mailto(to,subject,msg) Send mail. mailto('root', 'sub', 'msg')
max_start_time(date) Return true if the date specified on argument is on the future. max_start_time('12:00')
master_connection_is_ok() Return true if master connection is ready master_connection_is_ok()

Eric 2005-12-17