查看用法:
[root@super65 ~]# salt-run -d|grep jobs
'jobs.active:' #查看当前执行的job
Return a report on all actively running jobs from a job id centric
salt-run jobs.active
'jobs.list_job:'
salt-run jobs.list_job 20130916125524463507
'jobs.list_jobs:'
List all detectable jobs and associated functions
salt-run jobs.list_jobs
'jobs.lookup_jid:'
salt-run jobs.lookup_jid 20130916125524463507
salt-run jobs.lookup_jid 20130916125524463507 outputter=highstate
'jobs.print_job:'
salt-run jobs.print_job 20130916125524463507
[root@super65 ~]# salt 'super66' cmd.run 'sleep 100;ls'
^CExiting on Ctrl-C
This job's jid is:
20160917113447042036
The minions may not have all finished running and any remaining minions will return upon completion. To look up the return data for this job later run:
salt-run jobs.lookup_jid 20160917113447042036
查看当前运行的job:
[root@super65 ~]# salt-run jobs.active
20160917113447042036:
----------
Arguments:
- sleep 100;ls
Function:
cmd.run
Returned:
Running:
|_
----------
super66:
6115
Target:
super66
Target-type:
glob
User:
root
查看job执行的结果:
[root@super65 ~]# salt-run jobs.lookup_jid 20160917113447042036
super66:
Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos
anaconda-ks.cfg
install.log
install.log.syslog
查看job执行详细过程:
[root@super65 ~]# salt-run jobs.list_job 20160917113447042036
Arguments:
- sleep 100;ls
Function:
cmd.run
Minions:
- super66
..........
通过modules管理job:
查看使用帮助:
[root@super65 ~]# salt * sys.doc saltutil |grep job
'saltutil.find_cached_job:' #查询job cache信息
Return the data for a specific cached job id
salt '*' saltutil.find_cached_job <job id>
'saltutil.find_job:' #查看job信息
Return the data for a specific job id
salt '*' saltutil.find_job <job id>
'saltutil.kill_job:' #kill job(sigterm 9)
Sends a kill signal (SIGKILL 9) to the named salt job's process
salt '*' saltutil.kill_job <job id>
salt '*' saltutil.runner jobs.list_jobs
'saltutil.signal_job:'
Sends a signal to the named salt job's process
salt '*' saltutil.signal_job <job id> 15
'saltutil.term_job:' #删除job (sigterm 15)
Sends a termination signal (SIGTERM 15) to the named salt job's process
salt '*' saltutil.term_job <job id>
查看当前正在运行job:
[root@super65 ~]# salt '*' saltutil.running
super66:
super65.cn: