一、简介

Jid: job id的格式为%Y%m%d%H%M%S%f

master在下发指令消息时,会附带上产生的jid,minion在接收到指令开始执行时,会在本地的cachedir(默认是/var/cache/salt/minion)下的proc目录下产生该jid命名的文件,用于在执行过程中master查看当前任务执行的情况,在指令执行完毕蒋结果传送给master后,删除该临时文件。 master将minion的执行结果存放在本地/var/cache/salt/master/jobs目录中,默认缓存24小时(可以通过修改master配置文件中keepjobs选项调整)

在执行指令时添加 -v 选项可以显示命令执行的job id 如:

[root@master reactor]# salt -v 'master' test.ping
Executing job with jid #可以显示任务的Job id
------------------------------------------- master:
True -------------------------------------------
Summary
-------------------------------------------
# of minions targeted:
# of minions returned:
# of minions that did not return:
# of minions with errors:
-------------------------------------------
[root@master reactor]#

二、Job基本管理

saltutil模块中的job管理方法

通过salt  *  sys.doc saltutil |grep job

[root@master reactor]# salt master sys.doc saltutil | grep job
saltutil.clear_job_cache:
Forcibly removes job cache folders and files on a minion.
salt '*' saltutil.clear_job_cache hours=
saltutil.find_cached_job:
Return the data for a specific cached job id. Note this only works if
cache_jobs has previously been set to True on the minion.
salt '*' saltutil.find_cached_job <job id>
saltutil.find_job:
Return the data for a specific job id that is currently running.
The job id to search for and return data.
salt '*' saltutil.find_job <job id>
Note that the find_job function only returns job information when the job is still running. If
the job is currently running, the output looks something like this:
# salt my-minion saltutil.find_job
If the job has already completed, the job cannot be found and therefore the function returns
# salt my-minion saltutil.find_job
saltutil.kill_all_jobs:
Sends a kill signal (SIGKILL ) to all currently running jobs
salt '*' saltutil.kill_all_jobs
saltutil.kill_job:
Sends a kill signal (SIGKILL ) to the named salt job's process
salt '*' saltutil.kill_job <job id>
salt master_minion saltutil.runner jobs.list_jobs
saltutil.signal_job:
Sends a signal to the named salt job's process
salt '*' saltutil.signal_job <job id>
saltutil.term_all_jobs:
Sends a termination signal (SIGTERM ) to all currently running jobs
salt '*' saltutil.term_all_jobs
saltutil.term_job:
Sends a termination signal (SIGTERM ) to the named salt job's process
salt '*' saltutil.term_job <job id>

1、salt '*' saltutil.running            #查看minion当前正在运行的jobs

2、salt '*' saltutil.find_job <jid>            #查看指定jid的job(minion正在运行的jobs)

3、salt '*' saltutil.signal_job <jid> <single>    #给指定的jid进程发送信号

4、salt '*' saltutil.term_job <jid>        #终止指定的jid进程(信号为15)

5、salt '*' saltutil.kill_job <jid>          #终止指定的jid进程(信号为9)

salt runner中的job管理方法

可以执行salt-run -d |grep jobs  查看到相关jobs命令

[root@master reactor]# salt-run  -d | grep jobs
jobs.active:
Return a report on all actively running jobs from a job id centric
salt-run jobs.active
jobs.exit_success:
salt-run jobs.exit_success
jobs.last_run:
List all detectable jobs and associated functions
salt-run jobs.last_run
salt-run jobs.last_run target=nodename
salt-run jobs.last_run function='cmd.run'
salt-run jobs.last_run metadata="{'foo': 'bar'}"
jobs.list_job:
salt-run jobs.list_job
salt-run jobs.list_job --out=pprint
jobs.list_jobs:
List all detectable jobs and associated functions
If more than one of the below options are used, only jobs which match
salt-run jobs.list_jobs search_metadata='{"foo": "bar", "baz": "qux"}'
Can be passed as a string or a list. Returns jobs which match the
salt-run jobs.list_jobs search_function='test.*'
salt-run jobs.list_jobs search_function='["test.*", "pkg.install"]'
salt-run jobs.list_jobs search_function='test.*,pkg.install'
Can be passed as a string or a list. Returns jobs which match the
salt-run jobs.list_jobs search_target='*.mydomain.tld'
salt-run jobs.list_jobs search_target='["db*", "myminion"]'
salt-run jobs.list_jobs search_target='db*,myminion'
module is not installed, this argument will be ignored). Returns jobs
module is not installed, this argument will be ignored). Returns jobs
salt-run jobs.list_jobs
salt-run jobs.list_jobs search_function='test.*' search_target='localhost' search_metadata='{"bar": "foo"}'
salt-run jobs.list_jobs start_time='2015, Mar 16 19:00' end_time='2015, Mar 18 22:00'
jobs.list_jobs_filter:
List all detectable jobs and associated functions
salt-run jobs.list_jobs_filter
salt-run jobs.list_jobs_filter filter_find_job=False
jobs.lookup_jid:
salt-run jobs.lookup_jid
salt-run jobs.lookup_jid --out=highstate
jobs.print_job:
salt-run jobs.print_job
It can also be used to schedule jobs directly on the master, for example:
[root@master reactor]#

1、salt-run jobs.active                 #查看所有minion当前正在运行的jobs(在所有minions上运行saltutil.running)

2、salt-run jobs.lookup_jid <jid>         #从master jobs cache中查询指定jid的运行结果

3、salt-run jobs.list_jobs                #列出当前master jobs cache中所有job

    

SaltSack 中Job管理的更多相关文章

  1. 深入理解Linux中内存管理

    前一段时间看了<深入理解Linux内核>对其中的内存管理部分花了不少时间,但是还是有很多问题不是很清楚,最近又花了一些时间复习了一下,在这里记录下自己的理解和对Linux中内存管理的一些看 ...

  2. Git 在小团队中的管理流程(转)

    目标读者:了解 Git 的基本概念,能够使用 Git 进行基本的本地和远程操作. 有关 Git 的基础知识可以参见 知乎回答-怎样使用 GitHub?,天猪(刘勇)给出了一些很好的学习资料. 本文介绍 ...

  3. SQL Server中TempDB管理(version store的逻辑结构)

    原文:SQL Server中TempDB管理(version store的逻辑结构) 原文来自: http://blogs.msdn.com/b/sqlserverstorageengine/arch ...

  4. SQL Server中TempDB管理(版本存储区的一个example)

    原文:SQL Server中TempDB管理(版本存储区的一个example) 原文来自: http://blogs.msdn.com/b/sqlserverstorageengine/archive ...

  5. 【转】Linux中包管理与定时任务

    [转]Linux中包管理与定时任务 第1章 软件查询 1.1 查询软件是否安装 rpm -qa |grep cron 查询是否安装了这个软件. [root@znix ~]# rpm -qa |grep ...

  6. C#编程(七十三)----------浅析C#中内存管理

    浅析C#中内存管理 前言:个人觉得C#吸收了各种语言的优点,可谓集大成者,但是不知但,这种集所有语言于一身的情况是好是坏.C#编程的一个优点就是程序员不需要关心具体的内存管理,尤其是垃圾收集器会处理所 ...

  7. [转载]对iOS开发中内存管理的一点总结与理解

    对iOS开发中内存管理的一点总结与理解   做iOS开发也已经有两年的时间,觉得有必要沉下心去整理一些东西了,特别是一些基础的东西,虽然现在有ARC这种东西,但是我一直也没有去用过,个人觉得对内存操作 ...

  8. Atitit. 软件开发中的管理哲学--一个伟大的事业必然是过程导向为主 过程导向 vs 结果导向

    Atitit. 软件开发中的管理哲学--一个伟大的事业必然是过程导向为主    过程导向 vs 结果导向 1. 一个伟大的事业必然是过程导向为主 1 1.1. 过程的执行情况(有明确的执行手册及标准) ...

  9. <p>在我们的实际软件项目中,管理团队事实上比写代码或者实现一个客户的需求更为的有挑战性。由于编程实际上是和机器打交道,而和机器打交道,仅仅要你符合机器预定的逻辑,</p>

    在我们的实际软件项目中,管理团队事实上比写代码或者实现一个客户的需求更为的有挑战性. 由于编程实际上是和机器打交道.而和机器打交道,仅仅要你符合机器预定的逻辑, 一步步迈向解决这个问题的道路上一点都不 ...

随机推荐

  1. DNS bind9安装

    参考   111 首先要成功安装Centos操作系统,最新版本是Centos 6.4版本,最小化安装. [root@localhost named]# ifconfig -a     0 1 eth1 ...

  2. Python Learning Day8

    bp4解析库 pip3 install beautifulsoup4 # 安装bs4pip3 install lxml # 下载lxml解析器 html_doc = """ ...

  3. 深度理解js中var let const 区别

    首先要理解js中作用域的概念 作用域:指的是一个变量的作用范围 1.全局作用域 直接写在script中的js代码,在js中,万物皆对象,都在全局作用域,全局作用域在页面打开时创建,在全局作用域中有一个 ...

  4. 吴裕雄--天生自然 JAVASCRIPT开发学习:语法

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. react动态生成列表

    在组件的render函数中遍历数组menus[]并且要return返回虚拟Dom对象. render() { return createPortal( this.state.visible & ...

  6. JZOJ-2019-11-5 B组

    T1 给出一二维01矩阵\(f_{i,j}\), 定义点\((x_a, y_a), (x_b, y_b)\)的「距离」为\(max\{|x_a-x_b|, |y_a-y_b|\}\) 求出一矩阵\(w ...

  7. java 的二分算法

    二分算法 就是在 一组 有序 数组中 通过中间值(数组中间的那个数字)的方法 找到 某个数的下标,如果大于中间值 ,则在中间值与最大值之间 的中间值再比较. public class two { // ...

  8. It can be a face application using SeetaFace and Qt.

    之前编译了一下SeetaFace的库,用于人脸检测.特征点定位和人脸识别的功能,然后昨天就用Qt写了一个软件用于实现. 工程的文件还是比较简单的,一个界面类和一个SeetaFace的线程类而已.这里主 ...

  9. HDU 3018 欧拉回路

    HDU - 3018 Ant Country consist of N towns.There are M roads connecting the towns. Ant Tony,together ...

  10. 吴裕雄--天生自然 PHP开发学习:函数

    <?php function writeName() { echo "Kai Jim Refsnes"; } echo "My name is "; wr ...