Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Synchronize Scripts Between Routing Engines

Learn about the different methods to synchronize automation scripts between Routing Engines.

You have several options available to synchronize commit, event, lib, op, and SNMP scripts between Routing Engines on a Junos device. You can synchronize scripts between Routing Engines when you perform a commit operation. You can also synchronize scripts as needed using operational mode commands. Alternatively, you can configure the device to automatically synchronize scripts when you commit and synchronize the configuration. The device synchronizes scripts from the Routing Engine on which you execute the request (the requesting Routing Engine) to the other Routing Engine (the responding Routing Engine).

The following sections outline the different methods for synchronizing scripts.

Overview of Script Synchronization Between Routing Engines

You can synchronize commit, event, lib, op, and SNMP scripts between Routing Engines on Junos devices. Table 1 provides an overview of the different methods for synchronizing scripts.

Table 1: Methods to Synchronize Scripts
Method Device Mode Description

request system scripts synchronize

Operational mode command

Synchronize one or more scripts based on script type, filename, or timestamp.

commit synchronize scripts

Configuration mode command

Synchronize all scripts when you commit and synchronize the configuration.

[edit system scripts]
synchronize;

Configuration statement

Configure the device to synchronize scripts whenever you issue a commit synchonize command.

request system scripts refresh-from sync

Operational mode command

Refresh a single script from a remote URL and synchronize it to the other Routing Engine.

In operational mode, you can synchronize scripts from the requesting Routing Engine to the responding Routing Engine by issuing the request system scripts synchronize command. You can customize the scope of the synchronization. You can synchronize a single script, all scripts of a specific type, or all scripts on the device. You also have the option to synchronize scripts based on the filename or the timestamp of the file.

In configuration mode, you have the option to synchronize all scripts when you commit and synchronize the configuration. To synchronize scripts on a per-commit basis, use the commit synchronize scripts command when you commit and synchronize the configuration. You might use this option if you have a large number of scripts that are infrequently updated and you only want to synchronize the scripts as needed. Alternatively, you can configure the device to automatically synchronize all scripts every time you issue a commit synchronize command. To ensure that all scripts are synchronized during a commit synchronize operation, configure the synchronize statement at the [edit system scripts] hierarchy level.

When you synchronize the configuration and scripts during a commit operation, the device:

  1. Performs a commit check on the requesting Routing Engine

  2. Synchronizes the scripts to the other Routing Engine

  3. Synchronizes the configuration to the other Routing Engine

  4. Performs a commit check on the other Routing Engine

  5. Commits the configuration on the other Routing Engine

  6. Commits the configuration on the requesting Routing Engine

This order of operations ensures that any commit scripts that are required for a successful commit operation are present on the responding Routing Engine before committing the configuration. If the commit check operation fails for the requesting Routing Engine, the process stops, and the device does not copy the scripts to the responding Routing Engine. If the commit check or commit operation fails for the responding Routing Engine, the device still synchronizes the scripts since the synchronize operation occurs before the commit check operation on the responding Routing Engine.

When synchronizing scripts, the device determines the script source and destination directories based on the presence of the load-scripts-from-flash statement in the configuration of each Routing Engine. If the load-scripts-from-flash statement is present in the requesting Routing Engine configuration, the device synchronizes the scripts that are in flash memory. Otherwise, the device synchronizes the scripts that are on the hard disk. If the load-scripts-from-flash statement is present in the final configuration for the responding Routing Engine, the device synchronizes the scripts to flash memory. Otherwise, the device synchronizes the scripts to the hard disk. The device synchronizes a script even if you have not enabled the script in the configuration or updated the script since it was last synchronized.

The request system scripts refresh-from operational mode command enables you to refresh a single script from a remote URL. You can synchronize the updated script to the other Routing Engine at the same time by including the sync option in the command. If the load-scripts-from-flash statement is configured on the Routing Engine, the device refreshes the script in flash memory. Otherwise, the device refreshes the script on the hard disk.

Configure Script Synchronization for Commit Synchronize Operations

You can configure a Junos device to synchronize all commit, event, lib, op, and SNMP scripts from the requesting Routing Engine to the other Routing Engine every time you issue the commit synchronize command to commit and synchronize the configuration.

To automatically synchronize scripts between Routing Engines during a commit synchronize operation:

  1. Configure the synchronize statement at the [edit system scripts] hierarchy level.
  2. Commit and synchronize the configuration.

When you issue the first and subsequent commit synchronize commands, the device synchronizes the scripts and configuration to the other Routing Engine as outlined in Overview of Script Synchronization Between Routing Engines. If the commit check operation fails for the requesting Routing Engine, the process stops, and the device does not copy the scripts to the responding Routing Engine. If the commit check or commit operation fails for the responding Routing Engine, the scripts are still synchronized since the synchronize operation occurs before the commit check operation on the responding Routing Engine.

After you configure the synchronize statement, the device synchronizes all scripts even if you have not updated the scripts since they were last synchronized. If the device has a large number of scripts that are infrequently updated, it might be more suitable to synchronize scripts either manually using the request system scripts synchronize operational mode command or on a per-commit basis using the commit synchronize scripts command.

Synchronize Scripts on a Per-Commit Basis

You can synchronize all commit, event, lib, op, and SNMP scripts from the requesting Routing Engine to the other Routing Engine on a per-commit basis. You might use this method if you have a large number of scripts that you do not update frequently and you only want to synchronize the scripts as needed.

To synchronize scripts between Routing Engines on a per-commit basis:

  1. Make your changes to the configuration.
  2. Issue the commit synchronize scripts command.

When you issue the commit synchronize scripts command, the device synchronizes the scripts and configuration to the other Routing Engine as outlined in Overview of Script Synchronization Between Routing Engines. If the commit check operation fails for the requesting Routing Engine, the process stops, and the device does not copy the scripts to the responding Routing Engine. If the commit check or commit operation fails for the responding Routing Engine, the scripts are still synchronized since the synchronize operation occurs before the commit check operation on the responding Routing Engine.

Synchronize Scripts Between Routing Engines in Operational Mode

You can use the request system scripts synchronize operational mode command to synchronize scripts from the requesting Routing Engine to the other Routing Engine. You can synchronize a single script, all scripts of a specific type, or all scripts on the device. You also have the option to synchronize scripts based on the filename or on the timestamp of the file.

To synchronize scripts between Routing Engines, issue the request system scripts synchronize command with your required options.

Specify all to synchronize all scripts present on the requesting Routing Engine to the responding Routing Engine. Specify commit, event, lib, op, or snmp to synchronize all scripts of the given type to the other Routing Engine. Include the file option or the newer-than option to narrow the scope to only synchronize scripts with the specified filename or date criteria. The format for the newer-than argument is YYYY-MM-DD.HH:MM:SS.

For example, the following command synchronizes all commit, event, lib, op, and SNMP scripts that have a timestamp newer than 2025-05-15:

The following command synchronizes a single op script with the filename vpn-info.slax:

A synchronize operation might fail, for example, if the script does not exist or if the responding Routing Engine cannot handle the request at that time because it is performing other CPU-intensive operations. If the synchronize operation fails, the device generates an error message.

The following command requests to synchronize a single event script. The script does not exist in the event scripts directory, so the device issues an error.

The following command requests to synchronize a single event script. The responding Routing Engine does not have the resources to perform the operation, so the device issues an error. The device also logs a UI_SCRIPTS_COPY_FAILED error in the system log file with a severity level of error.

Refresh and Synchronize a Script

You can refresh a single script from a remote URL and then synchronize the updated script to the other Routing Engine. To refresh and synchronize a script, issue the request system scripts refresh-from command with the sync option. Specify the script type, filename, and remote URL. Specify the URL as an HTTP URL, FTP URL, or scp-style remote file specification.

The system uses the script type to determine the directory where the script resides. If the load-scripts-from-flash statement is present in the configuration for the Routing Engine, the system refreshes the script in flash memory. Otherwise, the system refreshes the script on the hard disk.

Example: Synchronize Scripts Between Routing Engines

This example configures a dual Routing Engine device to synchronize all commit, event, lib, op, and SNMP scripts to the other Routing Engine every time you execute a commit synchronize operation.

Requirements

A dual Routing Engine device running Junos OS or Junos OS Evolved.

Overview

In this example, you configure a dual Routing Engine device to synchronize all scripts to the other Routing Engine when you issue a commit synchronize command. The device synchronizes all commit, event, lib, op, and SNMP scripts, even if you have not enabled the script in the configuration.

This example does not configure the load-scripts-from-flash statement on the requesting Routing Engine. Thus, the device synchronizes the scripts that are on the hard disk of the requesting Routing Engine to the hard disk of the responding Routing Engine.

Configuration

CLI Quick Configuration

To quickly configure this example, copy the following command, paste it in a text file, and then copy and paste the command into the CLI at the [edit] hierarchy level.

Configuring Script Synchronization for Commit Synchronize Operations

Step-by-Step Procedure

To automatically synchronize scripts between Routing Engines during a commit synchronize operation:

  1. Configure the synchronize statement at the [edit system scripts] hierarchy level.

  2. Commit and synchronize the configuration.

    When you issue the first and subsequent commit synchronize commands, the device synchronizes the scripts and configuration to the other Routing Engine.

Results

The resulting configuration is:

Verification

Confirm that the configuration is working properly and the synchronization is successful.

Verify Script Synchronization

Purpose

Verify that the device synchronized the scripts from the requesting Routing Engine to the other Routing Engine.

In this example, the device synchronizes scripts from the /var/db/scripts directory on the requesting Routing Engine to the /var/db/scripts directory on the responding Routing Engine.

Action

Use the file list operational mode command to view the files in the /var/db/scripts directory on each Routing Engine.

  1. On the requesting Routing Engine, list the files under the /var/db/scripts/ directory.

  2. Verify that the files are synchronized to the other Routing Engine.

Meaning

The scripts are identical on each Routing Engine indicating that the device successfully synchronized the scripts from the requesting Routing Engine to the responding Routing Engine.

Troubleshooting

Troubleshoot Script Synchronization Failure

Problem

The device does not synchronize the scripts from the requesting Routing Engine to the other Routing Engine.

Solution

Verify the following:

  • You configured the synchronize statement at the [edit system scripts] hierarchy level.

  • You are viewing the correct directories on each Routing Engine.

    If the load-scripts-from-flash statement is present in the requesting and responding Routing Engine configurations, the device synchronizes scripts from the flash drive on the requesting Routing Engine to the flash drive on the responding Routing Engine.

  • You executed a commit synchronize command when you committed the configuration.

    The device only synchronizes scripts for a commit synchronize operation. The device does not synchronize scripts for a commit operation.

  • The commit check and commit operations for the requesting Routing Engine are successful.

    If the commit check operation for the requesting Routing Engine fails, the process stops, and the device does not copy the scripts to the responding Routing Engine.