Infrastructure 2017-09-26

Setting Up Cron with Ansible

Configure cron jobs with Ansible playbooks using YAML syntax and the cron module for task scheduling and automation.

Read in: ja
Setting Up Cron with Ansible

Overview

This task involves setting up cron with Ansible.

Playbook

Below is an example configuration to execute a task every minute.

---
- hosts: vps
  become: yes
  user: root
  tasks:
  - name: Output recently logined users
    cron:
     name: last.sh
     job: last.sh
     minute: "*/1"

A point to note is that if you want to write */1, you need to enclose it in double quotes. If not enclosed, a syntax error will occur. (Need to study YAML more... lol)

Thoughts

The cron setup went smoothly without any issues.

Reference

Tags: Ansible cron
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles