Controlling Execution of Commit Scripts During Commit Operations
Commit scripts are stored on a router or switch’s hard
drive (in the /var/db/scripts/commit directory) or flash drive (in the /config/scripts/commit directory); for more information, see Storing Commit Scripts in Flash Memory. However, a commit
script is not actually executed during commit operations unless its
filename is included at the [edit system scripts commit file] hierarchy level. To prevent execution of a commit script, delete
the commit script’s filename at that hierarchy level.
By default, the commit operation fails unless all scripts included at the [edit system scripts commit file] hierarchy level actually exist in the commit script directory. To enable the commit operation to succeed even if a script is missing, include the optional statement at the [edit system scripts commit file filename] hierarchy level. For example, you might want to mark a script as optional if you anticipate the need to quickly remove it from operation by deleting it from the commit script directory, but do not want to remove the commit script filename at the [edit system scripts commit file] hierarchy level. To enable use of the script again later, you simply replace the file in the commit script directory.
![]() |
Caution: When you include the optional statement at the [edit system scripts commit file filename] hierarchy level, no error message is generated during the commit operation if the file does not exist. As a result, you might not become aware that a script is not executed as you expect. |
You can also deactivate and reactivate commit scripts by issuing the deactivate and activate configuration mode commands. When a commit script is deactivated, the script is marked as inactive in the configuration and does not execute during the commit operation. When a commit script is reactivated, the script is again executed during the commit operation.
To determine which commit scripts are currently active on the
router, either list the contents of the /var/run/scripts/commit directory or use the show command to display the files
included (but not marked inactive:) at the [edit system
scripts commit] hierarchy level.
The filename of a commit script written in SLAX must include the .slax extension for the script to be executed. No particular filename extension is required for commit scripts written in XSLT, but we strongly recommend that you append the .xsl extension.
See the following sections:
Enabling Commit Scripts to Execute During Commit Operations
To configure a commit script to execute during a commit operation, follow these steps:
- Ensure that the commit script is located in the
correct directory: the
/var/db/scripts/commitdirectory on the hard drive or the/config/scripts/commitdirectory on the flash drive. For more information about script storage location, see Storing Commit Scripts in Flash Memory. -
Enable the commit script by including the file filename statement at the [edit system scripts commit] hierarchy level. Only users who belong to the JUNOS super-user login class can enable commit scripts.
- filename—Name of the commit script.
- optional—Enable the commit operation to succeed when the script file does not exist in the script directory. If this statement is omitted, the commit operation fails if the script does not exist.
The commit script does not execute during this commit operation, but executes automatically during each subsequent commit operation.
Preventing Commit Scripts from Executing During Commit Operations
To prevent a commit script from executing during a commit operation, follow these steps:
-
filename—Name of the commit script.
Delete the commit script filename at the [edit system scripts commit] hierarchy level:
- [edit system scripts commit]
- user@host# delete file filename
- Remove the commit script from the commit script directory. Although removing the commit script from the commit script directory is not necessary, it is always a good policy to delete unused files from the system.
Deactivating Commit Scripts
To deactivate a commit script, follow these steps:
A deactivated commit script is marked as inactive: and ignored during a commit operation.
In this example, the script mycommit.slax is deactivated:
- [edit]
- user@host# deactivate system scripts commit
file mycommit.slax
- [edit]
- user@host# show system scripts commit
- inactive: file mycommit.slax
Activating Commit Scripts
To activate an inactive commit script, follow these steps:
The commit script does not execute during this commit operation, but executes automatically during each subsequent commit operation.


