Schedule a Sync

Category: Directory Connector
On this page:

    For Organizations using the Directory Connector CLI, automatic syncs can be scheduled on defined intervals as an alternative to using the Desktop Applications Interval setting. This is particularly useful in headless environments, on in circumstances where a Desktop Application cannot be left running in the background.


    In Unix-like environments, including Linux and macOS, use cron to schedule Directory Connector sync jobs:

    Cron Permissions

    When running a cron job, we recommend doing so as a dedicated Directory Connector user. Create a bwdc user if you haven’t already, and add that user to the etc/cron.allow list. This will allow a non-Root user to set up and run cron jobs.

    In order to continue, you will also need your Organization’s API Key client_id and client_secret, which can be obtained by an Organization Owner from the Web Vault by navigating to Organization SettingsMy Organization.

    Setup a Sync Script

    In order avoid session timeouts, we recommend creating a shell script to run through cron. This script should securely read your client_secret to complete the login, and run a bwdc sync command that writes output to bwdc.log. If you need help creating a sync script, Contact Us.

    Setup the Cron Job

    As the permitted bwdc user:

    1. Edit the user’s crontab file by entering crontab -e in the terminal, or as edit the crontab file as any user by entering crontab -u <bwdc_username> -e.
    2. Add a line to the crontab that includes:
      • A scheduling expression that will determine the time/recurrence interval on which to execute the desired command (e.g. 0 0 * * 2 to run every Tuesday at midnight).
      • The command to execute at the specified time/recurrence interval. In this case, execute the previously created sync script (e.g.

    For example, to run the sync script every Monday at 12:00:

    # 0 12 * * 1

    Cron Job Scheduling Expressions

    Use the following reference when scheduling syncs via cron to ensure you’re scheduling them for the desired time:

    # ┌───────────── minute (0 - 59)
    # │ ┌───────────── hour (0 - 23)
    # │ │ ┌───────────── day of the month (1 - 31)
    # │ │ │ ┌───────────── month (1 - 12)
    # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
    # │ │ │ │ │                                   7 is also Sunday on some systems)
    # │ │ │ │ │
    # │ │ │ │ │
    # * * * * * <command to execute>

    If you’re not yet comfortable with cron job scheduling expressions, check out for help.

    Please note, this is a third-party resource that is not operated or maintained by Bitwarden.