Skip to main content
ndumaj
Staff
Staff
October 28, 2025

Technical Tip: How to perform an FortiNAC reboot or restart NAC service using a custom script on a scheduler

  • October 28, 2025
  • 0 replies
  • 475 views
Description This article describes how to run a script out of the scheduler to run FortiNAC reboot or restart NAC service based on a schedule.
Scope FortiNAC.
Solution
  • FortiNAC Reboot custom script:

Create a script file 'Run-Reboot' under /home/cm/scripts:

 

execute enter-shell
$ cd /home/cm/scripts/

$ vi Run-Reboot

#!/bin/sh
# -------------------------------------------------------
# Script Name : Run-Reboot
# Purpose : Executes a safe system reboot with sudo
# Location : /home/cm/scripts
# -------------------------------------------------------

# Check if environment file .yams exists
if [ -e /bsc/campusMgr/bin/.yams ]; then
. /bsc/campusMgr/bin/.yams
else
. /root/.profile
fi

# Go to the main directory (optional)
cd /bsc/campusMgr/bin

# Display a message
echo "Executing system reboot with sudo..."

# Execute reboot command
sudo /sbin/reboot

exit 0

List the file under the /home/cm/scripts directory:

/home/cm/scripts$ ll
total 32
20 -rwxrwxr-x 1 nac cmdb 15972 May 14 18:20 ServiceNow.example*
8 -rwxrwxr-x 1 nac cmdb 1244 May 14 18:20 RunSharedReports*
4 -rw-r--r-- 1 admin admin 563 Oct 27 16:36 Run-Reboot

Make the script executable:


$ chmod +x Run-Reboot

 

List:

 

$ ll
total 32
20 -rwxrwxr-x 1 nac cmdb 15972 May 14 18:20 ServiceNow.example*
8 -rwxrwxr-x 1 nac cmdb 1244 May 14 18:20 RunSharedReports*
4 -rwxrwxr-x 1 nac cmdb 563 Oct 27 16:36 Run-Reboot*

 

Create the scheduler in the FortiNAC GUI:

 

Add a new Scheduler Activity:


Figure 1. Add a new Scheduler Activity.Figure 1. Add a new Scheduler Activity.


Based on business requirements, define the Scheduled Type:


Figure 2. Scheduler type.Figure 2. Scheduler type.

 

  • Restart the NAC service custom script.

On FortiNAC CLI, under /home/cm/scripts create a custom script file named 'RestartNAC':

execute enter-shell
$ cd /home/cm/scripts/

$ vi RestartNAC

 

sudo systemctl restart nac

// use ESC button

:wq                ---> use :wq to save the file

Verify the file under the /home/cm/scripts directory:

/home/cm/scripts$ ll RestartNAC
total 32
4 -rw-r--r-- 1 admin admin 563 Oct 27 16:36 restartNAC

To utilize the script on FortiNAC GUI 'Scheduler' make the script executable using the following command on FortiNAC CLI:

$ chmod +x restartNAC

/home/cm/scripts$ ll RestartNAC
total 40
4 -rwxrwxr-x 1 nac cmdb 57 Mar 10 16:57 restartNAC*

On FortiNAC GUI, System -> Scheduler -> Create New Scheduled Activity using Custom script and utilize the restartNAC script under command:

Figure 3. Create a new RestartNAC Scheduler Activity.Figure 3. Create a new RestartNAC Scheduler Activity.

 

Scheduled Type can be defined as either a Repetitive, a Once, or a Fixed Day.

Troubleshoot:

To troubleshoot scheduler tasks activity, enable the following debug processes in FortiNAC:

 

execute enter-shell

diagnose debug plugin enable SchedulerInterface

diagnose tail -F output.master

 

Manually run the script from Scheduler View and verify the output.master log.


Relevant administration guide section: Add a task.

Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!