Salt (4) 任务:Jobs
http://docs.saltstack.com/en/latest/topics/jobs/
每次通过 salt 执行一个命令(salt module) / state / highstate,salt 都建一个 job。管理在 /var/cache/salt/proc
。
saltutil 封装的命令
running
Returns the data of all running jobs that are found in the proc directory.find_job
Returns specific data about a certain job based on job id.signal_job
Allows for a given jid to be sent a signal.term_job
Sends a termination signal (SIGTERM, 15) to the process controlling the specified job.kill_job
Sends a kill signal (SIGKILL, 9) to the process controlling the specified job.
用法:
salt '*' saltutil.running
jobs runner 封装的命令
jobs runner 是专为操作 jobs 设计的命令。它的输出会比 saltutil 更易读,而且功能更多。如果你的命令是 --async
执行的,那么在知道 jid
后,就需要 looup_jid
来不断尝试去获取执行结果了。
用法:
# 相当于 saltutil.running,结果更易读
salt-run jobs.active
# 列出所有 jobs,便于查找 jid (job id number)
salt-run jobs.list_jobs
# 查看某个 job 的运行结果
salt-run jobs.lookup_jid <job id number>
comments powered by Disqus