How to delay the directory sync on startup in Confluence

Still need help?

The Atlassian Community is here for you.

Ask the community


In larger environments with over 1000 LDAP groups, or over 10,000 users, the LDAP sync on Confluence startup can take a long time to complete. This occurs on startup and in some cases can prevent users from logging into the product until the sync is complete. 

This article explains how to delay this sync, which will allow for Confluence to complete startup in a reasonable amount of time and allow users to login. The sync can be scheduled to run during off-peak hours to minimize the impact. 

This article will serve the purpose of a workaround until this feature request is implemented:  CONFSERVER-22326 - Getting issue details... STATUS

Solution - Dynamic Sync Start Time

To delay the directory sync on startup of Confluence, set a value in milliseconds for which the sync should be delayed. 

  • Add the following jvm parameter to <confluence-install>/bin/ (or setenv.bat in Windows), or your custom startup script: 

  • For example, if you wish to delay the sync by 12 hours: 

  • Restart Confluence for the changes to take effect.

This will start the sync 12 hours after Confluence starts, effectively allowing Confluence to be fully up and running and not waiting on a sync to complete before becoming available to users.

Solution - Fixed Sync Start Time

If you wish to use a fixed time, such as 3am to perform the syncs, you can define the number of milliseconds at startup dynamically by creating a variable:

  • Add the following to your <confluence-install>/bin/ file: 

    TIME_TO_3AM_IN_MS=$(($(($((86400+$(($(date -d "03:00" +%s)-$(date +%s)))))%86400))*1000))
    echo "On startup, initial crowd sync will be delayed up to 3AM, which is in $TIME_TO_3AM_IN_MS ms."
    CATALINA_OPTS="-Dcrowd.polling.startdelay=$TIME_TO_3AM_IN_MS $CATALINA_OPTS"
  • Or, 7pm for example: 

    TIME_TO_7PM_IN_MS=$(($(($((86400+$(($(date -d "19:00" +%s)-$(date +%s)))))%86400))*1000))
    echo "On startup, initial crowd sync will be delayed up to 7PM, which is in $TIME_TO_7PM_IN_MS ms."
    CATALINA_OPTS="-Dcrowd.polling.startdelay=$TIME_TO_7PM_IN_MS ${CATALINA_OPTS}"
  • Restart Confluence for the changes to take effect.

Breakdown of each step above

# 3am in seconds
3AM_IN_SECONDS=$(date -d "03:00" +%s)

# current time in seconds

# difference between the above

# add 1 day, modulo 1 day, in case the date command retrieved 3am in the past, causing a negative time difference
# Note that modulo of a negative number *should* be positive according to mathematics but shell script doesn't do this correctly, which is why the day has to be added first
ADJUSTED_TIME_DIFF=$(($((86400 + $TIME_DIFF)) % 86400))

# multiply by 1000 to get ms instead of seconds


  • While this KB article was written for Confluence, this JVM parameter can also be applied in other applications.
  • Please note that this parameter is currently not working in newer versions of Crowd. See the following Crowd bug for more details CWD-5437 - Getting issue details... STATUS
  • On Confluence Data Center the directory synchronization schedule works on different way and the parameter described in this KB doesn't work out of the box. See the following Confluence bug for more details CONFSERVER-60516 - Getting issue details... STATUS

Last modified on Nov 30, 2020

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.