计划时间触发器
2025/10/29大约 4 分钟
计划时间触发器
计划时间触发器(Schedule trigger)可以按照计划时间来触发自动化流程,支持的计划类型如下:
- 每小时(hourly):指定在每小时的特定分钟循环触发。
- 每天(daily):指定在每天的特定小时和分钟循环触发。
- 每周(weekly):指定在每周的特定某天的小时和分钟循环触发。
- 每月(monthly):指定在每月的特定某天的小时和分钟循环触发。
- 单次(once):指定在特定的年/月/日/小时/分钟触发一次。
config system automation-trigger
edit <name>
set trigger-type scheduled
set trigger-frequency {hourly | daily | weekly | monthly | once}
set trigger-hour <inetger>
set trigger-minute <integer>
set trigger-weekday {sunday | monday | tuesday | wednesday | thursday | friday | saturday}
set trigger-day <integer>
set trigger-datetime <YYYY-MM-DD HH:MM:SS>
next
end网络需求
在每天的凌晨 3 点备份 FortiGate 的配置文件到 FTP 服务器,备份的配置文件名称中要包含备份的日期。
配置步骤
进入 FortiGate 的“Security Fabric → 自动化 → 触发器”页面,点击“新建”按钮。

在弹出的页面的“其他条件”分类中点击“计划任务”。

配置触发器名称,计划任务频率选择“每天”,小时填写“3”,分钟保持默认“0”(24 小时表示法),点击确认下发配置。


config system automation-trigger edit "Daily_3am" set trigger-type scheduled set trigger-hour 3 next end进入 FortiGate 的“Security Fabric → 自动化 → 操作”页面,点击“新建”按钮。

在弹出的页面的“通用”分类中点击“CLI 脚本”。

配置动作名称,脚本中填写备份配置到 FTP 服务器的 CLI 命令,点击确认下发配置。

config system automation-action edit "Backup_config_to_FTP" set action-type cli-script set script "exe backup config ftp AutoBackup_%%date%%.conf 192.168.100.110 backup 111111" set accprofile "super_admin" next endAutoBackup_%%date%%.conf表示备份到 FTP 服务器的配置文件名称,其中%%date%%是一个变量,表示备份时的日期。192.168.100.110为 FTP 服务器的 IP,如果 FTP 服务器使用的是非 21 端口,则需要在 IP 后添加加:<port>,如192.168.100.110:2121。backup:FTP 用户名。111111:FTP 用户密码。
进入 FortiGate 的“Security Fabric → 自动化 → 工作流”页面,点击“新建”按钮。

配置工作流(Stitch 的)名称,在触发中选择步骤 3 创建的触发器,在 Action 中选择步骤 6 创建的动作,点击“确认”下发配置。

config system automation-stitch edit "Auto_backup" set trigger "Daily_3am" config actions edit 1 set action "Backup_config_to_FTP" set required enable next end next end
结果验证
等待自动化流程被触发,检查 FortiGate 自动备份并上传到 FTP 服务器上的配置文件,可以看到文件名字与自动化 Action 中配置的 CLI 脚本的格式一致,包含备份日期。

查看 FortiGate 的自动化触发日志,可以看到该自动化流程在凌晨 3 点被触发并完成执行对应动作。
date=2024-03-13 time=03:00:17 eventtime=1710316517425603720 tz="+0800" logid="0100046600" type="event" subtype="system" level="notice" vd="root" logdesc="Automation stitch triggered" stitch="Auto_backup" trigger="Daily_3am" stitchaction="Backup_config_to_FTP" from="scheduled" msg="stitch:Auto_backup is triggered." date=2024-03-13 time=03:00:22 eventtime=1710316522252196480 tz="+0800" logid="0100032549" type="event" subtype="system" level="information" vd="root" logdesc="Autoscript stop automatically" msg="script autod.10 stopped automatically" date=2024-03-13 time=15:55:22 eventtime=1710316522239782720 tz="+0800" logid="0100032142" type="event" subtype="system" level="notice" vd="root" logdesc="System configuration backed up" ui="auto-script" action="backup" msg="User backed up the configuration from auto-script"查看自动化触发的 Debug 信息,可以看到整个触发和执行备份配置文件到 FTP 的全部过程。
FortiGate # diagnose debug application autod -1 FortiGate # diagnose debug enable __action_cli_script_open()-186: cli script action:Backup_config_to_FTP is called. svc ctx:0xa1cabf0 accprof:super_admin script: exe backup config ftp AutoBackup_%%date%%.conf 192.168.100.110 backup 111111 pid:283-__handle_msg()-414: Subscriber:4 received package. pubid:2 pkgid:65017 pkg_index:0 pid:283-__handle_pkg_logs()-356: Subscriber:4 processing package size:1198 logs:1 pickup:1 auto_event_pub_handle_log()-331: publish 46600 to subscr-node pid:283-__subscr_close_cur_pkg()-140: close package size:1198 logs:1 __cli_script_close()-121: cli script: autod.10 output: ########## script name: autod.10 ########## ========== #1, 2024-03-13 15:55:17 ========== FW1_FGT101F $ exe backup config ftp AutoBackup_2024-03-13.conf 192.168.100.110 backup 111111 Connect to ftp server 192.168.100.110 ... Please wait... Send config file to ftp server OK. __action_cli_script_close()-213: cli script action is done. script: exe backup config ftp AutoBackup_%%date%%.conf 192.168.100.110 backup 111111 output: ########## script name: autod.10 ########## ========== #1, 2024-03-13 15:55:17 ========== FW1_FGT101F $ exe backup config ftp AutoBackup_2024-03-13.conf 192.168.100.110 backup 111111 Connect to ftp server 192.168.100.110 ... Please wait... Send config file to ftp server OK.查看该自动化流程的状态统计信息。
FortiGate # diagnose test application autod 3 alert mail log count: 0 stitch: Auto_backup (scheduled) local hit: 1 relayed to: 0 relayed from: 0 last trigger:Wed Mar 13 15:55:17 2024 last relay: next scheduled trigger:Thu Mar 14 15:55:00 2024 actions: Backup_config_to_FTP: done: 1 relayed to: 0 relayed from: 0 last trigger:Wed Mar 13 03:00:17 2024 last relay: logid to stitch mapping: id:0 (scheduled stitches) local hit: 1 relayed hits: 0 Auto_backup log category to stitch mapping:附备份配置文件的 CLI 命令格式。
FTP: execute backup config ftp <backup_filename> <ftp_server>[<:ftp_port>] [<user_name>] [<password>] [<backup_password>] TFTP: execute backup config tftp <backup_filename> <tftp_servers> [<backup_password>] SFTP: execute backup config sftp <backup_filename> <sftp_server>[<:sftp_port>] <user> <password> [<backup_password>]