Perform scheduled scripted tasks on SMB devices

Document created by Günther W. Albrecht on Feb 6, 2018Last modified by Günther W. Albrecht on Mar 5, 2018
Version 3Show Document
  • View in full screen mode

Scripting is a weak point of SMB devices: You can easily perform scripted tasks after each boot process (see sk52520 How to run commands at boot on an SG80/600/700/1100/1400/1200R -- UserScript for details), but no cron job is possible as crond does not run in GAiA Embedded (although the command crontab exists, it is unusable). There is a procedure to enable crond (Spikefish Solutions Blog: Enabling cron, the scheduling service on 600 / 700 / 1100 / 1200R) if really needed. But e.g. to issue a scripted reboot every two weeks at a certain time, we can also trigger the script over a SSH connection from another device.


Details can be found in sk106836 How to configure SSH authentication using RSA key files on Security Gateway 80 / 600 / 700 / 1100 / 1200R/1400 appliance. Remember to keep the passphrase empty when generating the key pair ! First step is to run # bashUser on while in expert mode to enable login directly into expert mode and WinSCP access. On the SMB box, we then create the file /pfrm2.0/etc/ :

#!/bin/bash -f
date >> /pfrm2.0/etc/lastReboot
(echo y ) | reboot


On the unit that shall issue the command (based on GAiA or Unix) we follow sk95890 How to configure SSH authentication on Gaia OS using RSA key files and create /home/admin/ :

#!/bin/bash -f
ssh -i /home/admin/MyKey ip.x.x.x sh -l ./pfrm2.0/etc/


After first connect per ssh, the script is able to login and perform reboot automatically after being called using cron. This is easy e.g. on a Gaia device (in GAiA WebGUI, see under System Management > Job Scheduler). Such a script can also perform TP Updates automatically, but at different scheduled times for each blade using the online_update_cmd !

5 people found this helpful