SaltStack Using Cron with Salt - SaltStack

How to use Cron and Salt together?

Salt can be utilized alongside the Cron application. Utilizing the two applications together gives an incredible chance to mechanize Salt. While Salt gives an alternative to execute commands remotely, Cron enables it to keep running in a pre-planned or computerized way. Give us a chance to figure out how to utilize Cron and Salt together in this part.

What is Cron?

Cron is extremely helpful application in the Linux Environment. It enables to preset a command or content to keep running in an explicit date and time. It likewise enables to run an application in a customary interim, say day by day, week after week or each first day of the month.

Cron begins when the system begins and check the/and so on/crontab file for configuration subtleties. The/and so on/crontab has each application and its timetable in a different line as demonstrated as follows.

Each line has the below seven passage focuses, which are isolated by space and they are as per the following −

  • minute − minute of the hour and is between ‘0’ and ‘59’.
  • hour − hour and is specified in the 24-hour clock.
  • day_of_month − Day of the Month and is between 1 and 31. For example, the 10th of each month is 10.
  • month −A month specified and is specified numerically (0-12), or as the name of the month (e.g. May).
  • day_of_week − Day of the week is specified numerically (0-7) or as the name of the day (e.g. Sun).
  • user − User account under which the command runs.
  • cmd − The actual command and its arguments.

Here, * replaces, if nothing is assigned.

Salt Caller (salt-call)

Salt gives a CLI (Command Line Interface), salt-call to run the modules in the neighborhood flunky system itself rather than from the ace server utilizing the salt command. The salt call CLI underpins every one of the alternatives bolstered by salt command, yet run locally.

Salt Caller was at first intended to help investigating, however now, it tends to be utilized as an independent application.

Using salt-bring in cron

The salt-call CLI is helpful to plan salt activity utilizing Cron. For instance, to check the condition of the minion consistently at midnight, we can utilize salt-call alongside the choice – state.apply as demonstrated as follows.

/and so on/crontab

Here,

  • The state.apply function will check the salt configuration File for the flunky and check whether all activity characterized for the follower is appropriately designed.
  • Setting the path is a decent practice in light of the fact that occasionally the salt command may not be accessible in the system path.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SaltStack Topics