Oracle® Solaris Cluster 参考手册

退出打印视图

更新时间: 2014 年 7 月,E51743-01
 
 

scds_timerun (3HA)

名称

scds_timerun, scds_timerun_delay - 在给定时段内执行给定命令

用法概要

cc [flags…] –I /usr/cluster/include file –L /usr/cluster/lib 
     –l dsdev#include <rgm/libdsdev.h>
     scha_err_t scds_timerun(scds_handle_t handle, const char *command, 
     time_t timeout, int signal, int *cmd_exit_code);
     scha_err_t scds_timerun_delay(scds_handle_t handle, const char *command, 
     time_t timeout, int signal, int *cmd_exit_code);

描述

scds_timerun() 函数使用 hatimerun 执行指定命令。如果在 timeout 参数指定的分配时段内未完成该命令,scds_timerun() 将发送由 signal 参数指定的信号以终止该命令。

command 参数不支持 I/O 重定向。但是,您可以编写脚本以执行重定向,然后将此脚本加入 command 参数中,作为 scds_timerun() 需要执行的命令。

scds_timerun_delay()() 函数的行为与 scds_timerun() 基本相同,不同的是它在调用 hatimerun 命令时使用 –d(delay,延迟)命令行选项。此选项延迟启动超时时钟,直到命令已开始执行。在负载沉重的系统上,从子进程派生到指定的程序开始执行,这之间可能有几秒的延迟。使用 –d 选项避免了将额外的执行前时间计入所分配的超时时间。

参数

支持以下参数:

handle

scds_initialize(3HA) 返回的句柄

command

包含要运行的命令的字符串

timeout

分配用于运行命令的时间(秒)

signal

用于终止命令的信号(如果在超时到期时该命令仍在运行)。如果 signal = -1,那么将使用 SIGKILL。请参见 signal(3HEAD)

cmd_exit_code

执行命令返回的代码

返回值

scds_timerun() 函数返回以下值:

0

该函数成功。

非零值

该函数失败。

错误

SCHA_ERR_NOERR

已执行命令,且 cmd_exit_code 包含子程序的退出状态。

SCHA_ERR_INTERNAL

未发生超时,但其他某个错误已被 scds_timerun() 检测到,该错误不是子程序检测到的错误。或者 hatimerun(1M) 捕获到信号 SIGTERM

SCHA_ERR_INVAL

存在无效的输入参数。

SCHA_ERR_TIMEOUT

在由 command 参数指定的命令完成执行之前发生超时。

有关其他错误代码的描述,请参见 scha_calls(3HA)

文件

/usr/cluster/include/rgm/libdsdev.h

头文件

/usr/cluster/lib/libdsdev.so

属性

有关下列属性的说明,请参见 attributes(5)

属性类型
属性值
可用性
ha-cluster/developer/api
接口稳定性
Evolving(发展中)

另请参见

hatimerun(1M), scds_initialize(3HA), scha_calls(3HA), signal(3HEAD), attributes(5)