Scheduling jobs with cron
There are numerous occasions, no matter which infrastructure tier we work in, that we need to run automated tasks at some point of the day, week, month, and so on. In Linux systems, this functionality is achieved with cron. In this module, you will learn how to configure cron jobs using Salt modules.
How to do it...
We will use the salt-minion
minion that we configured in the previous recipe.
- Create a new state called
cron
in the staging environment. - Create and edit the
/opt/salt-cookbook/staging/cron/init.sls
file to have the following entries:clean_tomcat_logs: cron.present: - name: find /opt/apache-tomcat-6.0.43/logs/ -mtime +30 -exec rm -rf {} \; - user: root - minute: 00 - hour: 01 - daymonth: '*' - month: '*' - dayweek: ...
Get Salt Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.