Implementing Commit Scripts

To use a commit script on a switch, router, or security device, follow these steps:

  1. Write the commit script.

    For information about the types of commit scripts you can write, see Overview of Generating Custom Warning, Error, and System Log Messages, Overview of Generating Persistent or Transient Configuration Changes, and Overview of Creating Custom Configuration Syntax with Macros. For examples, see Commit Script Examples.

  2. Copy the script to the /var/db/scripts/commit directory on the hard drive or the /config/scripts/commit directory on the flash drive; for information about setting the storage location for scripts, see Storing Commit Scripts in Flash Memory. Only users who belong to the Junos OS super-user login class can access and edit files in these directories.

    Note: If the device has dual Routing Engines and you want to enable the commit script to execute on both Routing Engines, you must copy it to the /var/db/scripts/commit or /config/scripts/commit directory on both Routing Engines. The commit synchronize command does not automatically copy scripts between Routing Engines.

  3. Enable the script by including the file filename statement at the [edit system scripts commit] hierarchy level. For instructions, see Controlling Execution of Commit Scripts During Commit Operations.
  4. Issue the commit command.

The commit script does not execute during this commit operation, but executes automatically during each subsequent commit operation.