# Creating a staggered cron processes on the same host

**URL:** <https://forum.ansible.com/t/creating-a-staggered-cron-processes-on-the-same-host/28221>\
**Category:** Ansible Project\
**Created:** [August 1, 2018, 12:30am UTC](https://forum.ansible.com/t/creating-a-staggered-cron-processes-on-the-same-host/28221 "2018-08-01T00:30:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Muriithi](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@William\_Muriithi](https://forum.ansible.com/u/William_Muriithi)\
**Post date:** [August 1, 2018, 12:30am UTC](https://forum.ansible.com/t/creating-a-staggered-cron-processes-on-the-same-host/28221/1 "2018-08-01T00:30:37Z")

</div>

Evening all,

Got a quick question. Suppose you have a huge amount of data that you  
need to keep in sync between two systems. Running one session of  
rsync is taking a long time. I am attempting to break up the rsync  
session and have a separate rsync session per directory.

I would ideally like to start these rsync sessions in a staggered  
manner to avoid killing the system. The cron module does have a way to  
spread the tasks if they are running on different hosts, but I can't  
for the life of me figure out how to get it to generate random time  
depending on the directories name. Anyone done this before?

Below is what the task would look, but want to replace the seed if possible.

&nbsp;&nbsp;&nbsp;&nbsp;- name: cron jobs to trigger cron backup for tools directories  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cron: name="{{item}}" hour="{{23

> random(seed=inventory\_hostname)}}" minute="{{59 |random}}" user=root

job="/usr/local/bin/{{item}}\_backup.sh \> /dev/null"  
cron\_file={{item}}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- '{{tools\_directories}}'

Regards,  
William

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 1, 2018, 6:16am UTC](https://forum.ansible.com/t/creating-a-staggered-cron-processes-on-the-same-host/28221/2 "2018-08-01T06:16:16Z")

</div>

To influence the random, your option is to change the seed, that can be done by concatenate inventory\_hostname and item

&nbsp;&nbsp;&nbsp;random(seed=inventory\_hostname ~ item)
