O'Reilly logo

Salt Cookbook by Anirban Saha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

  1. Create a new state called cron in the staging environment.
  2. 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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required