2016-12-15 22:36:44 +00:00
|
|
|
.. _tutorial-cron-with-salt:
|
|
|
|
|
2012-11-09 18:24:00 +00:00
|
|
|
Using cron with Salt
|
2016-03-22 03:56:17 +00:00
|
|
|
====================
|
2012-11-09 18:24:00 +00:00
|
|
|
|
2016-03-22 03:56:17 +00:00
|
|
|
The Salt Minion can initiate its own :ref:`highstate <running-highstate>` using
|
|
|
|
the ``salt-call`` command.
|
2012-11-09 18:24:00 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-11-09 19:15:15 +00:00
|
|
|
|
2016-03-22 03:56:17 +00:00
|
|
|
$ salt-call state.apply
|
2012-11-09 18:24:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
This will cause the minion to check in with the master and ensure it is in the
|
2016-03-22 03:56:17 +00:00
|
|
|
correct "state".
|
2012-11-09 18:24:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
Use cron to initiate a highstate
|
|
|
|
================================
|
|
|
|
|
|
|
|
If you would like the Salt Minion to regularly check in with the master you can
|
2016-03-22 03:56:17 +00:00
|
|
|
use cron to run the ``salt-call`` command:
|
2012-11-09 18:24:00 +00:00
|
|
|
|
2012-11-09 19:15:15 +00:00
|
|
|
.. code-block:: bash
|
2012-11-09 18:24:00 +00:00
|
|
|
|
2016-03-22 03:56:17 +00:00
|
|
|
0 0 * * * salt-call state.apply
|
2012-11-09 19:06:35 +00:00
|
|
|
|
2016-03-22 03:56:17 +00:00
|
|
|
The above cron entry will run a :ref:`highstate <running-highstate>` every day
|
|
|
|
at midnight.
|
2012-11-09 19:25:14 +00:00
|
|
|
|
2014-12-11 15:50:14 +00:00
|
|
|
.. note::
|
2016-03-22 03:56:17 +00:00
|
|
|
When executing Salt using cron, keep in mind that the default PATH for cron
|
|
|
|
may not include the path for any scripts or commands used by Salt, and it
|
|
|
|
may be necessary to set the PATH accordingly in the crontab:
|
|
|
|
|
|
|
|
.. code-block:: cron
|
|
|
|
|
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin
|
|
|
|
|
|
|
|
0 0 * * * salt-call state.apply
|