Support Support Downloads Knowledge Base Juniper Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[SRX] How to schedule operational commands without using scripts



Article ID: KB22795 KB Last Updated: 29 Sep 2020Version: 2.0

This article provides information on how to take the output of certain commands at fixed intervals or at a particular time during the day. The output can be locally recorded or sent to an external server.


You can schedule, for monitoring and troubleshooting purposes, certain operational commands at regular intervals or fixed time of the day. Scripts can be used for this; but it might be hard to figure out when there is an issue with the script.

Junos Event-Options is used to perform the function of operational scripts.


The Event-Options feature allows you to perform predefined tasks, which are triggered based on the following types of events:

  • System-generated events

  • Manually generated events

In this case, you can use manually generated events, which can be triggered by users at specific times.


set event-options generate-event testEvent time-of-day "10:42:00 +0000"
set event-options policy Policy1 events testEvent
set event-options policy Policy1 then execute-commands commands "show system uptime"
set event-options policy Policy1 then execute-commands output-filename test1
set event-options policy Policy1 then execute-commands destination local-directory
set event-options destinations local-directory archive-sites /var/tmp/

Verify the configuration:

show event-options
generate-event {
   testEvent time-of-day "10:42:00 +0000";
policy Policy1 {
   events testEvent;
   then {
      execute-commands {
         commands {
            "show system uptime";
         output-filename test1;
         output-format text;
         destination local-directory;
destinations {
   local-directory {
      archive-sites {

This configuration will generate a testEvent at 10:42:00 +0000 every day. Policy1 will look for testEvent. Whenever this event is generated, the SRX device will record the output of the configured command in a local file in /var/tmp/.

The archive destination can be specified as:

  • Hypertext Transfer Protocol (HTTP) URL

  • FTP URL or

  • Secure copy (scp)-style remote file specification.

You can check the local directory by using the file list /var/tmp/ details operation mode command, after the scheduled time.

For more information, refer to Event Policy File Archiving Overview

The target filename will start with a underscore ( _ ), if the hostname (#set system hostname) is not configured for the device. If it is configured, the filename will start with the hostname.Note:

  •  A new file will be generated each time the event is triggered and the name of the new file will contain the corresponding time stamp; so the files will keep on archiving without any limit to the number of files. The output will not append to the previous file.

  • URLs of the file:/// type are not supported; however, local device directories are supported (for example, /var/tmp/).

  • If the generate-event option has time-interval in X seconds specified, then the event will be generated right at the commit of this config and after every X seconds.

  • If the generate-event option has time-of-day specified, then the event will be generated every day (24 hrs fixed interval) at the specified time.

  • Additionally, this configuration can also match system generated events. You can explore the events under set event-options policy <policy-name> events.

Modification History:
2020-09-28: Fixed broken link.
Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search