geerlingguy / ansible-for-devops

Ansible for DevOps examples.
https://www.ansiblefordevops.com
MIT License
8.52k stars 3.47k forks source link

Chapter 3 - Manage cron jobs #551

Open cshintov opened 1 year ago

cshintov commented 1 year ago

" If you want to run a shell script on all the servers every day at 4 a.m., add the cron job with: "

$ ansible multi -b -m cron -a "name='daily-cron-all-servers' \
hour=4 job='/path/to/daily-script.sh'”

But this runs the cron every minute of the hour because minute has default value *.

To run the cron only once at 4 a.m., we need to add minute=0 to the command.