一、简介

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. 十五、CI框架之自动加载数据库

    一.在config的autoload.php文件中,如果写入以下代码,那么在控制器中无需再次加载数据库了,相当于全局自动加载数据库了 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码 ...

  2. 利用方法HttpUtility.HtmlEncode来预处理用户输入

    利用方法HttpUtility.HtmlEncode来预处理用户输入.这样能阻止用户用链接注入JavaScript代码或HTML标记,比如//Store/Broswe?Genre=<script ...

  3. @Autowired注解与@Resource注解的区别(详细)

    相信对现在Java码农来说,@Autowired跟@Resource并不陌生,二者都可以自动注入,但是两者的区别很多时候并没有被注意到. 一.注解的出处 @Autowired是Spring提供的注解, ...

  4. 7.3 使用while 循环来处理列表和字典

    # 7.3.1 在列表之间移动元素 # confirmed_users.py # 首先,创建一个待验证用户列表 # 和一个用于存储已验证用户的空列表 uncomfirmed_users = ['jam ...

  5. Api_hook 拦截 messageBox 等函数

    library hookdll; uses SysUtils, Windows, Classes, unitHook in 'unitHook.pas'; {$R *.res} const HOOK_ ...

  6. LeetCode 543. Diameter of Binary Tree 二叉树的直径 (C++/Java)

    题目: Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of ...

  7. 磁盘报No space left on device,但是 df -h 查看磁盘空间没满

    df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/dev01-root 75G 58G 14G 82% / udev 2.0G ...

  8. Git 报错:Updates were rejected because the tip of your current branch is behind

    刚开始学习 git 命令,发现会出现很多的错误,所以就总结下出现的错误,以此来加深理解和掌握吧! 环境:在本地库操作了一系列的 add 和 commit 操作后,想把本地仓库推送到远端,但是发生以下错 ...

  9. UML-GoF设计模式-总结

    1.GRASP 2.设计模式

  10. 20个GitHub最热门的Java开源项目:文档、框架、工具

    专注于Java领域优质技术,欢迎关注 文章来源:JavaGuide 以下涉及到的数据统计,数据来源:https://github.com/trending/java?since=monthly[1] ...