After a lot of trials and errors I was able to make an expect script that reboots the FortiGates of my company on a weekly schedule.
For some reason I couldn't understand, trying to use an expect script to send the command "execute reboot" worked if I manually ran the script, but not inside a cron task. So after a lot of thought I realized that I could run two expect scripts: one that sends "set daily-restart enable" one hour before the chosen time and another script that sends "set daily-restart disable" one hour after the reboot.
I think it depends on the environment but I had some issues with expect in the past with other types of routers, missing the first character of the line. I would suggest you expect only distinctive last part of the line like emnoc showed.
Does this work if the firewall you want to reboot is part of an HA pair? I'd like to reboot the primary every night and want to be sure my secondary will not respect the 'daily-restart' when configs are sync'd:
config system global
set daily-restart enable
set restart-time 05:06
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.