2014-03-02 06:13:23 +00:00
|
|
|
=======================
|
|
|
|
:index:`Job Management`
|
|
|
|
=======================
|
2012-02-01 06:27:09 +00:00
|
|
|
|
|
|
|
.. versionadded:: 0.9.7
|
|
|
|
|
|
|
|
Since Salt executes jobs running on many systems, Salt needs to be able to
|
2014-02-19 23:57:04 +00:00
|
|
|
manage jobs running on many systems.
|
2012-02-01 06:27:09 +00:00
|
|
|
|
2014-03-02 06:13:23 +00:00
|
|
|
The :index:`Minion proc System`
|
|
|
|
===============================
|
2012-02-01 06:27:09 +00:00
|
|
|
|
2014-02-19 23:57:04 +00:00
|
|
|
Salt Minions maintain a *proc* directory in the Salt ``cachedir``. The *proc*
|
2012-05-23 04:43:12 +00:00
|
|
|
directory maintains files named after the executed job ID. These files contain
|
2012-02-01 06:27:09 +00:00
|
|
|
the information about the current running jobs on the minion and allow for
|
2012-05-23 04:43:12 +00:00
|
|
|
jobs to be looked up. This is located in the *proc* directory under the
|
|
|
|
cachedir, with a default configuration it is under */var/cache/salt/proc*.
|
2012-02-01 06:27:09 +00:00
|
|
|
|
|
|
|
Functions in the saltutil Module
|
|
|
|
================================
|
|
|
|
|
2012-03-19 01:04:25 +00:00
|
|
|
Salt 0.9.7 introduced a few new functions to the
|
|
|
|
:doc:`saltutil</ref/modules/all/salt.modules.saltutil>` module for managing
|
2012-02-01 06:27:09 +00:00
|
|
|
jobs. These functions are:
|
2012-03-19 01:04:25 +00:00
|
|
|
|
|
|
|
1. ``running``
|
2012-05-23 04:43:12 +00:00
|
|
|
Returns the data of all running jobs that are found in the *proc* directory.
|
2012-03-19 01:04:25 +00:00
|
|
|
|
|
|
|
2. ``find_job``
|
2012-02-01 06:27:09 +00:00
|
|
|
Returns specific data about a certain job based on job id.
|
2012-03-19 01:04:25 +00:00
|
|
|
|
|
|
|
3. ``signal_job``
|
2012-02-01 06:27:09 +00:00
|
|
|
Allows for a given jid to be sent a signal.
|
2012-03-19 01:04:25 +00:00
|
|
|
|
|
|
|
4. ``term_job``
|
2012-02-01 06:27:09 +00:00
|
|
|
Sends a termination signal (SIGTERM, 15) to the process controlling the
|
|
|
|
specified job.
|
2012-03-19 01:04:25 +00:00
|
|
|
|
|
|
|
5. ``kill_job``
|
2012-02-01 06:27:09 +00:00
|
|
|
Sends a kill signal (SIGKILL, 9) to the process controlling the
|
|
|
|
specified job.
|
|
|
|
|
|
|
|
These functions make up the core of the back end used to manage jobs at the
|
|
|
|
minion level.
|
|
|
|
|
|
|
|
The jobs Runner
|
|
|
|
===============
|
|
|
|
|
|
|
|
A convenience runner front end and reporting system has been added as well.
|
|
|
|
The jobs runner contains functions to make viewing data easier and cleaner.
|
|
|
|
|
|
|
|
The jobs runner contains a number of functions...
|
|
|
|
|
|
|
|
active
|
|
|
|
------
|
|
|
|
|
|
|
|
The active function runs saltutil.running on all minions and formats the
|
|
|
|
return data about all running jobs in a much more usable and compact format.
|
|
|
|
The active function will also compare jobs that have returned and jobs that
|
|
|
|
are still running, making it easier to see what systems have completed a job
|
|
|
|
and what systems are still being waited on.
|
|
|
|
|
2012-05-30 21:39:27 +00:00
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
# salt-run jobs.active
|
|
|
|
|
2012-02-01 06:27:09 +00:00
|
|
|
lookup_jid
|
|
|
|
----------
|
|
|
|
|
|
|
|
When jobs are executed the return data is sent back to the master and cached.
|
|
|
|
By default is is cached for 24 hours, but this can be configured via the
|
|
|
|
``keep_jobs`` option in the master configuration.
|
|
|
|
Using the lookup_jid runner will display the same return data that the initial
|
|
|
|
job invocation with the salt command would display.
|
|
|
|
|
2012-05-30 21:39:27 +00:00
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
# salt-run jobs.lookup_jid <job id number>
|
|
|
|
|
2012-02-01 06:27:09 +00:00
|
|
|
list_jobs
|
|
|
|
---------
|
|
|
|
|
|
|
|
Before finding a historic job, it may be required to find the job id. list_jobs
|
|
|
|
will parse the cached execution data and display all of the job data for jobs
|
|
|
|
that have already, or partially returned.
|
2012-05-30 21:39:27 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
# salt-run jobs.list_jobs
|
2014-02-25 00:42:53 +00:00
|
|
|
|
2014-03-02 06:13:23 +00:00
|
|
|
:index:`Scheduling Jobs`
|
|
|
|
========================
|
2014-02-25 00:42:53 +00:00
|
|
|
.. include:: schedule.rst
|
2014-02-26 20:32:08 +00:00
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:hidden:
|
|
|
|
|
|
|
|
schedule
|