Store Scripts in Flash Memory
By default, Junos OS automation scripts are stored in and executed from the /var/db/scripts directory on the device's hard disk under the subdirectory appropriate to the script type. Optionally, you can store automation scripts in and execute them from the device’s flash memory. In the unlikely event of a hard disk failure, storing scripts in flash memory reduces the impact of the failure because you can still access and execute the scripts. Changing the scripts’ physical location has no effect on their operation.
The flash memory partition is typically small and also stores the device’s active configuration, the last three committed configurations, and the rescue configuration, if it exists. Before storing scripts in flash memory, ensure that there is sufficient space to do so.
To instruct a device running Junos OS to load scripts from flash storage, configure the
load-scripts-from-flash statement at the [edit system
scripts] hierarchy level.
[edit] user@host# set system scripts load-scripts-from-flash user@host# commit
When you configure the load-scripts-from-flash statement, the device loads all
commit, event, op, SNMP, and script library scripts from the
/config/scripts directory in flash memory under the
subdirectory appropriate to the script type. You must manually move scripts from the
hard disk to flash memory. They are not moved automatically. Similarly, if you
delete the load-scripts-from-flash statement from the
configuration, you must manually copy the scripts from the flash memory to the hard
disk to ensure that the device executes the current versions of the scripts.
The system uses the /var/run/scripts directory as a means of finding the
current set of scripts. This path uses a symbolic link to reference either the
/var/db/scripts directory on the hard disk or the
/config/scripts directory in flash memory according to the
current setting of the load-scripts-from-flash statement. By
default, /var/run/scripts references the
/var/db/scripts directory on the device’s hard disk. If you
configure the load-scripts-from-flash statement,
/var/run/scripts references the
/config/scripts directory in flash memory.
user@host> file list detail /var/run/scripts lrwxr-xr-x 1 root wheel 16 Oct 15 11:27 /var/run/scripts@ -> /var/db/scripts/ total files: 1
To view the scripts on the device, list the contents
of /var/run/scripts/type, where type is the subdirectory appropriate
to the script type. In the following example, the load-scripts-from-flash statement is not configured. In this case, listing the files for /var/run/scripts/commit returns the files in the /var/db/scripts/commit directory.
user@host>file list /var/run/scripts/commit /var/run/scripts/commit: commit-changes-load-replace.slax commit-protect.slax
user@host> file list /var/db/scripts/commit /var/db/scripts/commit: commit-changes-load-replace.slax commit-protect.slax
user@host> file list /config/scripts/commit /config/scripts/commit: