Scheduling the execution of SNS CLI scripts
Scripts can be scheduled to run at a given date and time using the web interface or command line. For example, you can schedule an update of your SNS firewalls. Refer to the section Updating firewalls by using SNS CLI scripts.
- In the web interface of the SMC server, select Deployment > SNS CLI scripts.
- In the Firewalls selection tab, select the script to run.
- In the Optional: attachments related to the script menu, select the relevant files to attach to the script. For more information, please refer to the section Attaching files to a script and receiving files generated by script.
- In the second part of the Firewalls selection tab, select the firewalls on which the script will be run. For each firewall, in the View script column:
- The icon indicates, where applicable, that the firewall cannot be selected to run the script. The row will be grayed out in this case. Scroll over the icon with your mouse to find out why.
- The icon makes it possible to view the contents of the script, including variables replaced with values associated with the firewall in question. The icon becomes if there is an error during the analysis of the script (missing attached file or unknown variable). View the contents of the script to find out which row is causing the issue.
- Click on Schedule script at the bottom of the tab.
- Indicate the date and time to run the script. The time chosen here corresponds to the time on the SMC server.
- Click on Apply.
- An indicator at the top of the tab serves as a reminder of the script schedule. The only actions that can be performed are viewing the script, downloading the script or canceling the scheduled run.
- View the results of the script run in the Execution tab when it is complete.
Only one script run can be scheduled at a time.
You cannot run another script while a script has been scheduled and is awaiting its run.
IMPORTANT
The read/write privileges on any administration sessions already open on the firewalls in question are automatically adopted when a script is run.
The at
shell command makes it possible to schedule the execution of tasks. Among other functions, it allows the execution of the command smc-sns-cli-script
to be scheduled.
As several tasks can be scheduled, they will be run in sequence.
- Log in to the SMC server via the console of your hypervisor or in SSH.
- Type the command
at
followed by the desired date and time in the format below:at hh:mm MM/DD/YYYY
- Type the command
smc-sns-cli-script
followed by (in this order):- one of the subcommands described in the section Running the SNS CLI script in command line,
- the name of the script,
- the name of the firewalls concerned or the --all option to designate all firewalls,
[root@smc] - {~} > at 16:00 10/15/2019
warning: commands will be executed using /bin/sh
at> smc-sns-cli-script run monitor_qos.script --all
at> smc-sns-cli-script run monitor_stat.script --all
- Type Ctrl + D to confirm.
at> < EOT >
job 15 at Tue Oct 15 16:00:00 2019
- After the scheduled date and time of the run, you can check the results in the folder /data/tmp/sns-cli/output/. This folder contains a set of sub-folders named according to the date on which the scripts were run. To view the results of the execution of a script on a given firewall, look up the file output.log in one of these sub-folders.
If you need to attach files to the script, refer to the section Attaching files to a script and receiving files generated by script.
To see the list of scheduled tasks, use the atq
command.
To delete a scheduled task, use the atrm
command.