├── luci-app-taskplan ├── root │ ├── etc │ │ ├── taskplan │ │ │ ├── taskplancustomscript │ │ │ ├── taskplancustomscript2 │ │ │ └── taskplanrun │ │ ├── uci-defaults │ │ │ └── luci-taskplan │ │ ├── config │ │ │ └── taskplan │ │ └── init.d │ │ │ └── taskplan │ └── usr │ │ ├── share │ │ └── rpcd │ │ │ └── acl.d │ │ │ └── luci-app-taskplan.json │ │ └── bin │ │ └── taskplanhandler ├── luasrc │ ├── model │ │ └── cbi │ │ │ └── taskplan │ │ │ ├── log.lua │ │ │ ├── startuptask.lua │ │ │ └── scheduledtask.lua │ ├── controller │ │ └── taskplan.lua │ └── view │ │ └── taskplan │ │ └── log.htm ├── Makefile └── po │ ├── zh-cn │ └── taskplan.po │ └── zh_Hans │ └── taskplan.po ├── doc ├── view.png ├── view2.png ├── taskplan1.png ├── taskplan2.png └── taskplan3.png ├── LICENSE ├── .github └── workflows │ └── main.yml ├── README_CN.md └── README.md /luci-app-taskplan/root/etc/taskplan/taskplancustomscript: -------------------------------------------------------------------------------- 1 | # Sh script rules 2 | -------------------------------------------------------------------------------- /luci-app-taskplan/root/etc/taskplan/taskplancustomscript2: -------------------------------------------------------------------------------- 1 | # Sh script2 rules -------------------------------------------------------------------------------- /doc/view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirpdboy/luci-app-taskplan/HEAD/doc/view.png -------------------------------------------------------------------------------- /doc/view2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirpdboy/luci-app-taskplan/HEAD/doc/view2.png -------------------------------------------------------------------------------- /luci-app-taskplan/root/etc/taskplan/taskplanrun: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "" 4 | exit 0 -------------------------------------------------------------------------------- /doc/taskplan1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirpdboy/luci-app-taskplan/HEAD/doc/taskplan1.png -------------------------------------------------------------------------------- /doc/taskplan2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirpdboy/luci-app-taskplan/HEAD/doc/taskplan2.png -------------------------------------------------------------------------------- /doc/taskplan3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sirpdboy/luci-app-taskplan/HEAD/doc/taskplan3.png -------------------------------------------------------------------------------- /luci-app-taskplan/root/usr/share/rpcd/acl.d/luci-app-taskplan.json: -------------------------------------------------------------------------------- 1 | { 2 | "luci-app-taskplan": { 3 | "description": "Grant UCI access for luci-app-taskplan", 4 | "read": { 5 | "uci": [ "taskplan" ] 6 | }, 7 | "write": { 8 | "uci": [ "taskplan" ] 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /luci-app-taskplan/luasrc/model/cbi/taskplan/log.lua: -------------------------------------------------------------------------------- 1 | local fs = require "nixio.fs" 2 | local uci = require"luci.model.uci".cursor() 3 | local f, t 4 | f = SimpleForm("logview") 5 | f.reset = false 6 | f.submit = false 7 | t=f:field(TextValue,"conf") 8 | 9 | t.rmempty=true 10 | t.rows=20 11 | t.template="taskplan/log" 12 | t.readonly="readonly" 13 | return f 14 | -------------------------------------------------------------------------------- /luci-app-taskplan/root/etc/uci-defaults/luci-taskplan: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | chmod +x /etc/init.d/taskplan /usr/bin/taskplanhandler /etc/init.d/taskplanrun 3 | uci -q batch <<-EOF >/dev/null 4 | delete ucitrack.@taskplan[-1] 5 | add ucitrack taskplan 6 | set ucitrack.@taskplan[-1].init="taskplan" 7 | commit ucitrack 8 | EOF 9 | rm -rf /tmp/luci-modulecache /tmp/luci-indexcache* 10 | exit 0 -------------------------------------------------------------------------------- /luci-app-taskplan/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2019-2025 sirpdboy 3 | # 4 | # This is free software, licensed under the Apache License, Version 2.0 . 5 | # 6 | 7 | include $(TOPDIR)/rules.mk 8 | 9 | NAME:=taskplan 10 | PKG_NAME:=luci-app-$(NAME) 11 | LUCI_TITLE:=LuCI support for Task Plan setting 12 | LUCI_PKGARCH:=all 13 | 14 | PKG_VERSION:=2.3.1 15 | PKG_RELEASE:=20251023 16 | 17 | 18 | define Package/$(PKG_NAME)/conffiles 19 | /etc/config/taskplan 20 | endef 21 | 22 | include $(TOPDIR)/feeds/luci/luci.mk 23 | 24 | # call BuildPackage - OpenWrt buildroot signature 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2020 johnrosen1 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | 8 | jobs: 9 | build: 10 | name: Build ${{ matrix.arch }} 11 | runs-on: ubuntu-latest 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | arch: 16 | - aarch64_generic 17 | - i386_pentium-mmx 18 | - loongarch64_generic 19 | - mips_mips32 20 | - mipsel_24kc 21 | - mipsel_mips32 22 | - x86_64 23 | steps: 24 | - uses: actions/checkout@main 25 | with: 26 | fetch-depth: 0 27 | - name: Building packages 28 | uses: sbwml/openwrt-gh-action-sdk@go1.24 29 | env: 30 | ARCH: ${{ matrix.arch }}-openwrt-24.10 31 | FEEDNAME: packages_ci 32 | PACKAGES: luci-app-autotimeset 33 | NO_REFRESH_CHECK: true 34 | 35 | - name: Upload artifacts 36 | uses: actions/upload-artifact@v4 37 | with: 38 | name: ${{ matrix.arch }} 39 | path: bin/packages/${{ matrix.arch }}/packages_ci/*.ipk 40 | 41 | - name: Upload packages 42 | uses: ncipollo/release-action@v1 43 | with: 44 | token: ${{ secrets.GITHUB_TOKEN }} 45 | allowUpdates: true 46 | replacesArtifacts: true 47 | artifacts: "bin/packages/${{ matrix.arch }}/packages_ci/*.ipk" 48 | -------------------------------------------------------------------------------- /luci-app-taskplan/luasrc/controller/taskplan.lua: -------------------------------------------------------------------------------- 1 | module("luci.controller.taskplan",package.seeall) 2 | local fs=require"nixio.fs" 3 | local http=require"luci.http" 4 | function index() 5 | if not nixio.fs.access("/etc/config/taskplan") then 6 | return 7 | end 8 | entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false 9 | local e = entry({"admin", "control", "taskplan"}, alias("admin", "control", "taskplan", "scheduledtask"), _("Task Plan"), 20) 10 | e.dependent = false 11 | e.acl_depends = { "luci-app-taskplan" } 12 | entry({"admin", "control", "taskplan", "scheduledtask"}, cbi("taskplan/scheduledtask"), _("Scheduled task"), 10).leaf = true 13 | entry({"admin", "control", "taskplan", "startuptask"}, cbi("taskplan/startuptask"), _("Startup task"), 20).leaf = true 14 | entry({"admin", "control", "taskplan", "log"}, form("taskplan/log"), _("Log"), 30).leaf = true 15 | entry({"admin","control","taskplan","dellog"},call("dellog")) 16 | entry({"admin","control","taskplan","getlog"},call("getlog")) 17 | end 18 | 19 | function getlog() 20 | logfile="/etc/taskplan/taskplan.log" 21 | if not fs.access(logfile) then 22 | http.write("") 23 | return 24 | end 25 | local f=io.open(logfile,"r") 26 | local a=f:read("*a") or "" 27 | f:close() 28 | a=string.gsub(a,"\n$","") 29 | http.prepare_content("text/plain; charset=utf-8") 30 | http.write(a) 31 | end 32 | 33 | function dellog() 34 | fs.writefile("/etc/taskplan/taskplan.log","") 35 | http.prepare_content("application/json") 36 | http.write('') 37 | end 38 | -------------------------------------------------------------------------------- /luci-app-taskplan/root/etc/config/taskplan: -------------------------------------------------------------------------------- 1 | 2 | config global 3 | option enabled '0' 4 | option customscript '# Sh script rules' 5 | option customscript2 '# Sh script rules' 6 | 7 | config stime 8 | option hour '*/4' 9 | option stype '7' 10 | option week '*' 11 | option minute '0' 12 | option month '*' 13 | option enable '0' 14 | option ttype '0' 15 | option delay '10' 16 | option remarks '每月每天每过4小时执行一次' 17 | 18 | config stime 19 | option minute '0' 20 | option month '*' 21 | option enable '0' 22 | option delay '10' 23 | option stype '1' 24 | option ttype '0' 25 | option hour '1' 26 | option remarks '每月星期日1:00执行' 27 | option week '0' 28 | 29 | config stime 30 | option week '*' 31 | option month '*' 32 | option enable '0' 33 | option ttype '0' 34 | option delay '10' 35 | option stype '10' 36 | option minute '*/5' 37 | option hour '*' 38 | option remarks '每月每天每过5分钟执行' 39 | 40 | config stime 41 | option week '*' 42 | option stype '2' 43 | option month '*' 44 | option enable '0' 45 | option ttype '0' 46 | option delay '10' 47 | option remarks '每天22:30执行' 48 | option hour '22' 49 | option minute '30' 50 | 51 | config stime 52 | option minute '0' 53 | option enable '0' 54 | option ttype '0' 55 | option delay '10' 56 | option stype '6' 57 | option remarks '7月星期一到星期五22:00执行' 58 | option month '7' 59 | option week '1-5' 60 | option hour '22' 61 | 62 | config stime 63 | option week '*' 64 | option month '*' 65 | option stype '11' 66 | option ttype '1' 67 | option delay '20' 68 | option enable '0' 69 | option hour '*' 70 | option remarks '每月每天每过4分钟执行' 71 | option minute '*/4' 72 | 73 | config ltime 74 | option remarks '开机启动延时30秒执行' 75 | option stype '11' 76 | option delay '30' 77 | option enable '0' 78 | 79 | -------------------------------------------------------------------------------- /luci-app-taskplan/luasrc/view/taskplan/log.htm: -------------------------------------------------------------------------------- 1 | <%+cbi/valueheader%> 2 | 3 | <%:Reverse%> 4 | 5 | 6 | 54 | <%+cbi/valuefooter%> -------------------------------------------------------------------------------- /luci-app-taskplan/luasrc/model/cbi/taskplan/startuptask.lua: -------------------------------------------------------------------------------- 1 | 2 | local m,s,e 3 | 4 | m=Map("taskplan",translate("Startup task"),translate("The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts
") .. 5 | translate("The task to be executed upon startup, with a startup delay time unit of seconds.")) 6 | 7 | s = m:section(TypedSection, 'global') 8 | s.anonymous=true 9 | 10 | e=s:option(TextValue, "customscript" ,translate("Edit Custom Script")) 11 | e.description = translate("The execution content of the [Scheduled Customscript] in the task name") 12 | e.rows = 5 13 | e.default=" " 14 | 15 | e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2")) 16 | e.description = translate("The execution content of the [Scheduled Customscript2] in the task name") 17 | e.rows = 5 18 | e.default=" " 19 | 20 | s=m:section(TypedSection,"ltime","") 21 | s.addremove=true 22 | s.anonymous=true 23 | s.template = "cbi/tblsection" 24 | 25 | e = s:option(Value, 'remarks', translate('Remarks')) 26 | 27 | e=s:option(Flag,"enable",translate("Enable")) 28 | e.rmempty = false 29 | e.default=0 30 | 31 | e=s:option(ListValue,"stype",translate("Scheduled Type")) 32 | e:value(1,translate("Scheduled Reboot")) 33 | e:value(2,translate("Scheduled Poweroff")) 34 | e:value(3,translate("Scheduled ReNetwork")) 35 | e:value(4,translate("Scheduled RestartSamba")) 36 | e:value(5,translate("Scheduled Restartwan")) 37 | e:value(6,translate("Scheduled Closewan")) 38 | e:value(7,translate("Scheduled Clearmem")) 39 | e:value(8,translate("Scheduled Sysfree")) 40 | e:value(9,translate("Scheduled DisReconn")) 41 | e:value(10,translate("Scheduled DisRereboot")) 42 | e:value(11,translate("Scheduled Restartmwan3")) 43 | e:value(13,translate("Scheduled Wifiup")) 44 | e:value(14,translate("Scheduled Wifidown")) 45 | e:value(12,translate("Scheduled Customscript")) 46 | e:value(15,translate("Scheduled Customscript2")) 47 | e.default=2 48 | 49 | e=s:option(Value,"delay",translate("Delayed Start(seconds)")) 50 | e.default=10 51 | 52 | m.apply_on_parse = true 53 | m.on_after_apply = function(self,map) 54 | luci.sys.exec("/etc/init.d/taskplan start") 55 | end 56 | 57 | return m 58 | -------------------------------------------------------------------------------- /luci-app-taskplan/po/zh-cn/taskplan.po: -------------------------------------------------------------------------------- 1 | 2 | msgid "The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts
" 3 | msgstr "任务计划包括定时任务执行和开机启动任务执行,预置:重启、关机、重启网络、释放内存、系统清理、网络共享、关闭网络、自动检测断网重连、自动检测断网重启、MWAN3负载均衡检测重连、自定义脚本等10多个功能.
" 4 | 5 | msgid "N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours." 6 | msgstr "N1-N5连续,N1,N3,N5不连续,*/N表示每N小时或每N分钟。月份范围0-11,星期范围0~6,小时范围0~23,分钟范围0~59,不可用72小时或者90分钟等连续范围。" 7 | 8 | msgid "Scheduled task" 9 | msgstr "定时执行任务" 10 | 11 | msgid "Startup task" 12 | msgstr "开机启动任务" 13 | 14 | msgid "The task to be executed upon startup, with a startup delay time unit of seconds." 15 | msgstr "开机启动执行的任务,启动延时时间单位为秒。" 16 | 17 | msgid "Control" 18 | msgstr "管控" 19 | 20 | msgid "Task Plan" 21 | msgstr "任务设置" 22 | 23 | msgid "Test/Verify Settings" 24 | msgstr "测试/验证设置" 25 | 26 | msgid "Scheduled Type" 27 | msgstr "任务类型" 28 | 29 | msgid "Delayed Start(seconds)" 30 | msgstr "开机任务延时(秒)" 31 | 32 | msgid "Log" 33 | msgstr "日志" 34 | 35 | msgid "Scheduled Reboot" 36 | msgstr "重启机器" 37 | 38 | msgid "Scheduled Poweroff" 39 | msgstr "关闭机器" 40 | 41 | msgid "Scheduled ReNetwork" 42 | msgstr "重启网络" 43 | 44 | msgid "Scheduled RestartSamba" 45 | msgstr "重启网络共享" 46 | 47 | msgid "Scheduled Restartlan" 48 | msgstr "重启LAN" 49 | 50 | msgid "Scheduled Restartwan" 51 | msgstr "重启WAN" 52 | 53 | msgid "Scheduled Closewan" 54 | msgstr "关闭网络" 55 | 56 | msgid "Scheduled Clearmem" 57 | msgstr "释放内存" 58 | 59 | msgid "Scheduled Sysfree" 60 | msgstr "系统清理(会重启机器)" 61 | 62 | msgid "Scheduled DisReconn" 63 | msgstr "检测断网重连" 64 | 65 | msgid "Scheduled DisRereboot" 66 | msgstr "检测断网重启" 67 | 68 | msgid "Scheduled Restartmwan3" 69 | msgstr "检测MWAN3失联重启服务" 70 | 71 | msgid "Scheduled Wifidown" 72 | msgstr "关闭无线网络" 73 | 74 | msgid "Scheduled Wifiup" 75 | msgstr "启用无线网络" 76 | 77 | msgid "Edit Custom Script" 78 | msgstr "【自定义脚本】编辑" 79 | 80 | msgid "Edit Custom Script2" 81 | msgstr "【自定义脚本2】编辑" 82 | 83 | msgid "Scheduled Customscript" 84 | msgstr "自定义脚本" 85 | 86 | msgid "Scheduled Customscript2" 87 | msgstr "自定义脚本2" 88 | 89 | msgid "The execution content of the [Scheduled Customscript] in the task name" 90 | msgstr "任务名称中【自定义脚本】执行内容" 91 | 92 | msgid "The execution content of the [Scheduled Customscript2] in the task name" 93 | msgstr "任务名称中【自定义脚本2】执行内容" 94 | 95 | msgid "Month(0~11)" 96 | msgstr "月份(0~11)" 97 | 98 | msgid "Week Day(0~6)" 99 | msgstr "星期(0~6)" 100 | 101 | msgid "Everyday" 102 | msgstr "每天" 103 | 104 | msgid "Hour(0~23)" 105 | msgstr "小时(0~23)" 106 | 107 | msgid "Minute(0~59)" 108 | msgstr "分钟(0~59)" 109 | 110 | -------------------------------------------------------------------------------- /luci-app-taskplan/po/zh_Hans/taskplan.po: -------------------------------------------------------------------------------- 1 | 2 | msgid "The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts
" 3 | msgstr "任务计划包括定时任务执行和开机启动任务执行,预置:重启、关机、重启网络、释放内存、系统清理、网络共享、关闭网络、自动检测断网重连、自动检测断网重启、MWAN3负载均衡检测重连、自定义脚本等10多个功能.
" 4 | 5 | msgid "N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours." 6 | msgstr "N1-N5连续,N1,N3,N5不连续,*/N表示每N小时或每N分钟。月份范围0-11,星期范围0~6,小时范围0~23,分钟范围0~59,不可用72小时或者90分钟等连续范围。" 7 | 8 | msgid "Scheduled task" 9 | msgstr "定时执行任务" 10 | 11 | msgid "Startup task" 12 | msgstr "开机启动任务" 13 | 14 | msgid "The task to be executed upon startup, with a startup delay time unit of seconds." 15 | msgstr "开机启动执行的任务,启动延时时间单位为秒。" 16 | 17 | msgid "Control" 18 | msgstr "管控" 19 | 20 | msgid "Task Plan" 21 | msgstr "任务设置" 22 | 23 | msgid "Test/Verify Settings" 24 | msgstr "测试/验证设置" 25 | 26 | msgid "Scheduled Type" 27 | msgstr "任务类型" 28 | 29 | msgid "Delayed Start(seconds)" 30 | msgstr "开机任务延时(秒)" 31 | 32 | msgid "Log" 33 | msgstr "日志" 34 | 35 | msgid "Scheduled Reboot" 36 | msgstr "重启机器" 37 | 38 | msgid "Scheduled Poweroff" 39 | msgstr "关闭机器" 40 | 41 | msgid "Scheduled ReNetwork" 42 | msgstr "重启网络" 43 | 44 | msgid "Scheduled RestartSamba" 45 | msgstr "重启网络共享" 46 | 47 | msgid "Scheduled Restartlan" 48 | msgstr "重启LAN" 49 | 50 | msgid "Scheduled Restartwan" 51 | msgstr "重启WAN" 52 | 53 | msgid "Scheduled Closewan" 54 | msgstr "关闭网络" 55 | 56 | msgid "Scheduled Clearmem" 57 | msgstr "释放内存" 58 | 59 | msgid "Scheduled Sysfree" 60 | msgstr "系统清理(会重启机器)" 61 | 62 | msgid "Scheduled DisReconn" 63 | msgstr "检测断网重连" 64 | 65 | msgid "Scheduled DisRereboot" 66 | msgstr "检测断网重启" 67 | 68 | msgid "Scheduled Restartmwan3" 69 | msgstr "检测MWAN3失联重启服务" 70 | 71 | msgid "Scheduled Wifidown" 72 | msgstr "关闭无线网络" 73 | 74 | msgid "Scheduled Wifiup" 75 | msgstr "启用无线网络" 76 | 77 | msgid "Edit Custom Script" 78 | msgstr "【自定义脚本】编辑" 79 | 80 | msgid "Edit Custom Script2" 81 | msgstr "【自定义脚本2】编辑" 82 | 83 | msgid "Scheduled Customscript" 84 | msgstr "自定义脚本" 85 | 86 | msgid "Scheduled Customscript2" 87 | msgstr "自定义脚本2" 88 | 89 | msgid "The execution content of the [Scheduled Customscript] in the task name" 90 | msgstr "任务名称中【自定义脚本】执行内容" 91 | 92 | msgid "The execution content of the [Scheduled Customscript2] in the task name" 93 | msgstr "任务名称中【自定义脚本2】执行内容" 94 | 95 | msgid "Month(0~11)" 96 | msgstr "月份(0~11)" 97 | 98 | msgid "Week Day(0~6)" 99 | msgstr "星期(0~6)" 100 | 101 | msgid "Everyday" 102 | msgstr "每天" 103 | 104 | msgid "Hour(0~23)" 105 | msgstr "小时(0~23)" 106 | 107 | msgid "Minute(0~59)" 108 | msgstr "分钟(0~59)" 109 | 110 | -------------------------------------------------------------------------------- /luci-app-taskplan/luasrc/model/cbi/taskplan/scheduledtask.lua: -------------------------------------------------------------------------------- 1 | 2 | local m,s,e 3 | 4 | m=Map("taskplan",translate("Scheduled task"),translate("The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts
") .. 5 | translate("N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours.")) 6 | 7 | s = m:section(TypedSection, 'global') 8 | s.anonymous=true 9 | 10 | e=s:option(TextValue, "customscript" ,translate("Edit Custom Script")) 11 | e.description = translate("The execution content of the [Scheduled Customscript] in the task name") 12 | e.rows = 5 13 | e.default=" " 14 | 15 | e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2")) 16 | e.description = translate("The execution content of the [Scheduled Customscript2] in the task name") 17 | e.rows = 5 18 | e.default=" " 19 | 20 | s=m:section(TypedSection,"stime","") 21 | s.addremove=true 22 | s.anonymous=true 23 | s.template = "cbi/tblsection" 24 | 25 | e = s:option(Value, 'remarks', translate('Remarks')) 26 | 27 | e=s:option(Flag,"enable",translate("Enable")) 28 | e.rmempty = false 29 | e.default=0 30 | 31 | e=s:option(ListValue,"stype",translate("Scheduled Type")) 32 | e:value(1,translate("Scheduled Reboot")) 33 | e:value(2,translate("Scheduled Poweroff")) 34 | e:value(3,translate("Scheduled ReNetwork")) 35 | e:value(4,translate("Scheduled RestartSamba")) 36 | e:value(5,translate("Scheduled Restartwan")) 37 | e:value(6,translate("Scheduled Closewan")) 38 | e:value(7,translate("Scheduled Clearmem")) 39 | e:value(8,translate("Scheduled Sysfree")) 40 | e:value(9,translate("Scheduled DisReconn")) 41 | e:value(10,translate("Scheduled DisRereboot")) 42 | e:value(11,translate("Scheduled Restartmwan3")) 43 | e:value(13,translate("Scheduled Wifiup")) 44 | e:value(14,translate("Scheduled Wifidown")) 45 | e:value(12,translate("Scheduled Customscript")) 46 | e:value(15,translate("Scheduled Customscript2")) 47 | e.default=2 48 | 49 | 50 | e=s:option(Value,"month",translate("Month(0~11)")) 51 | e.rmempty = false 52 | e.default = '*' 53 | 54 | week=s:option(Value,"week",translate("Week Day(0~6)")) 55 | week.rmempty = true 56 | week:value('*',translate("Everyday")) 57 | week:value(0,translate("Sunday")) 58 | week:value(1,translate("Monday")) 59 | week:value(2,translate("Tuesday")) 60 | week:value(3,translate("Wednesday")) 61 | week:value(4,translate("Thursday")) 62 | week:value(5,translate("Friday")) 63 | week:value(6,translate("Saturday")) 64 | week.default='*' 65 | 66 | e=s:option(Value,"hour",translate("Hour(0~23)")) 67 | e.rmempty = false 68 | e.default = 0 69 | 70 | e=s:option(Value,"minute",translate("Minute(0~59)")) 71 | e.rmempty = false 72 | e.default = 0 73 | 74 | m.apply_on_parse = true 75 | m.on_after_apply = function(self,map) 76 | luci.sys.exec("/etc/init.d/taskplan start") 77 | end 78 | 79 | return m 80 | -------------------------------------------------------------------------------- /luci-app-taskplan/root/usr/bin/taskplanhandler: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # author 2021 jjm2473 3 | # author 2020-2024 sirpdboy 4 | TMP_T=/var/taskplan/taskplan.tmp 5 | LOG=/etc/taskplan/taskplan.log 6 | log(){ 7 | echo "$(date +'%Y-%m-%d %H:%M:%S') $*" >> $LOG 8 | } 9 | 10 | limit_log() { 11 | local logf=$1 12 | [ ! -f "$logf" ] && return 13 | local sc=100 14 | [ -n "$2" ] && sc=$2 15 | local count=$(grep -c "" $logf) 16 | if [ $count -gt $sc ];then 17 | let count=count-$sc 18 | sed -i "1,$count d" $logf 19 | fi 20 | } 21 | 22 | remwan3() { 23 | while true; do 24 | status=$(/usr/sbin/mwan3 status | grep error) 25 | if [ -z $status ]; then 26 | log "Mwan3 is OK" 27 | exit 1 28 | else 29 | log "mwan3 restarting ..." 30 | /usr/sbin/mwan3 restart 31 | fi 32 | sleep 60 33 | done 34 | } 35 | 36 | disreconnwan() { 37 | i=0 38 | PingA=114.114.114.114 39 | PingB=223.5.5.5 40 | while [[ $i -lt 5 ]] 41 | do 42 | if /bin/ping -c 1 $PingA >/dev/null 43 | then 44 | PingErr=0 45 | break 46 | else 47 | if /bin/ping -c 1 $PingB >/dev/null 48 | then 49 | PingErr=0 50 | break 51 | else 52 | i=$(($i + 1)) 53 | PingErr=1 54 | sleep 10 55 | fi 56 | fi 57 | done 58 | } 59 | 60 | trigger() { 61 | case "$1" in 62 | reboot) 63 | reboot 64 | ;; 65 | poweroff) 66 | poweroff 67 | ;; 68 | network) 69 | /etc/init.d/network restart 70 | ;; 71 | clearmem) 72 | sync && echo 3 > /proc/sys/vm/drop_caches 73 | ;; 74 | sysfree) 75 | cd /overlay 76 | rm -rf `ls | egrep -v '(upper|.fs_state)'` 77 | cd upper 78 | rm -rf `ls | egrep -v '(etc)'` 79 | cd etc 80 | rm -rf `ls | egrep -v '(config|ssr|bench.log|shadow)'` 81 | rm -rf /var/luci-modulecache 82 | rm -rf /var/luci-indexcache 83 | rm -rf /tmp/cache/* 84 | reboot 85 | ;; 86 | restartsamba) 87 | /etc/init.d/ksmdb restart 88 | /etc/init.d/samba restart 89 | /etc/init.d/samba4 restart 90 | ;; 91 | 92 | restartlan) 93 | ifdown lan && ifup lan 94 | log "restart lan succeeded!" 95 | ;; 96 | restartwan) 97 | ifup wan 98 | log "restart wan succeeded!" 99 | ;; 100 | closewan) 101 | ifdown wan 102 | ;; 103 | disreconn) 104 | disreconnwan 105 | if [ $PingErr = 1 ]; then 106 | ifup wan 107 | log "Redial succeeded!" 108 | fi 109 | ;; 110 | disrereboot) 111 | disreconnwan 112 | if [ $PingErr = 1 ]; then 113 | log "Reboot succeeded!" 114 | reboot 115 | fi 116 | ;; 117 | restartmwan3) 118 | [ -s /usr/sbin/mwan3 ] && remwan3 119 | ;; 120 | customscript) 121 | script=`cat /etc/taskplan/taskplancustomscript | wc -l` 122 | if [[ $script > 0 ]] ;then 123 | bash /etc/taskplan/taskplancustomscript 124 | log "CustomScript succeeded!" 125 | else 126 | log "CustomScript run Error!" 127 | fi 128 | ;; 129 | customscript2) 130 | script=`cat /etc/taskplan/taskplancustomscript2 | wc -l` 131 | if [[ $script > 0 ]] ;then 132 | bash /etc/taskplan/taskplancustomscript2 133 | log "CustomScript2 succeeded!" 134 | else 135 | log "CustomScript2 run Error!" 136 | fi 137 | ;; 138 | upwifi) 139 | ifconfig wlan0 up 140 | uci set wireless.radio0.disabled=0 141 | uci set wireless.radio1.disabled=0 142 | uci commit wireless 143 | wifi up 144 | ;; 145 | downwifi) 146 | ifconfig wlan0 down 147 | uci set wireless.radio0.disabled=1 148 | uci set wireless.radio1.disabled=1 149 | uci commit wireless 150 | wifi down 151 | ;; 152 | esac 153 | } 154 | 155 | limit_log $LOG 500 156 | PingErr=0 157 | log "Scheduled operation $2: $1" && trigger $1 158 | 159 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | ## 访问数:![hello](https://views.whatilearened.today/views/github/sirpdboy/deplives.svg)[![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ) 2 | 3 |

4 |
任务设置(taskplan)
5 |

6 | 7 |

8 | 9 | 10 | 11 | 12 |

13 | 14 | [中文] | [English](README.md) 15 | 16 | 17 | ![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明1.jpg) 18 | 19 | 请 **认真阅读完毕** 本页面,本页面包含注意事项和如何使用。 20 | 21 | ## 功能说明: 22 | 23 | ### 任务设置2.2.4版(taskplan) 24 | #### 2025.8.7 任务设置2.2.4版:修复新版自定义脚本有时候无效问题。 25 | 26 | ### 任务设置2.2.2版(taskplan) 27 | #### 2025.4.9 任务设置2.2.2版:修复新版导致开机启动任务无效问题。 28 | 29 | ### 任务设置2.2.1版(taskplan) 30 | #### 2025.3.19 任务设置2.2.1版:为和以前老版本做好区分重命名luci-app-taskplan,配适openwrt24.10. 31 | 32 | ### 定时设置2.0版 33 | #### 2023.5.23 定时设置2.0版:定时执行任务设置和开机启动任务设置二合一版,并增加自定义脚本功能。 34 | 35 | ### 定时设置1.9版 36 | #### 2023.4.1 定时设置1.9版:加入定时断网重连、定时检测WAN3重启等服务。 37 | 38 | ### 定时设置1.6版 39 | #### 2023.1.15 定时设置1.6版:重新代码制作优化。在之前的版本上新增加:定时清理内存、定时清理系统垃圾、定时断网、定时重启网络共享、定时重拨 等 8大功能 40 | 41 | ### 定时设置1.4版 42 | #### 2021.2.7 新增功能定时重启网络。现包括:定时重启、定时关机、定时重启网络,各功能可一起使用。 43 | 44 | ### 定时设置1.3版 45 | #### 2020.10.6 原来重定关机正式改名为定时设置,实现定时重启和定时关机功能二合一。 46 | 47 | ### 定时关机1.1版 48 | #### 2020.7.19 定时关机功能,彻底解决需要保存二次才生效的问题。 49 | 50 | ### 定时关机1.0版 51 | #### 2019.2.24 定时关机功能借鉴前辈们的开源代码首发。 52 | 53 | ## 编译使用方法 [![](https://img.shields.io/badge/-编译使用方法-F5F5F5.svg)](#编译使用方法-) 54 | 55 | 将luci-app-taskplan添加至 LEDE/OpenWRT 源码的方法。 56 | 57 | ### 下载源码方法一: 58 | 编辑源码文件夹根目录feeds.conf.default并加入如下内容: 59 | 60 | ```Brach 61 | # feeds获取源码: 62 | src-git taskplan https://github.com/sirpdboy/luci-app-taskplan 63 | ``` 64 | ```Brach 65 | # 更新feeds,并安装主题: 66 | scripts/feeds update taskplan 67 | scripts/feeds install luci-app-taskplan 68 | ``` 69 | 70 | ### 下载源码方法二: 71 | ```Brach 72 | # 下载源码 73 | git clone https://github.com/sirpdboy/luci-app-taskplan package/luci-app-taskplan 74 | make menuconfig 75 | ``` 76 | ### 配置菜单 77 | ```Brach 78 | make menuconfig 79 | # 找到 LuCI -> Applications, 选择 luci-app-taskplan, 保存后退出。 80 | ``` 81 | ### 编译 82 | ```Brach 83 | # 编译固件 84 | make package/luci-app-taskplan/compile V=s 85 | ``` 86 | 87 | ## 界面 88 | 89 | ![screenshots](./doc/taskplan1.png) 90 | 91 | ![screenshots](./doc/taskplan2.png) 92 | 93 | ![screenshots](./doc/taskplan3.png) 94 | 95 | 96 | ## 说明 [![](https://img.shields.io/badge/-说明-F5F5F5.svg)](#说明-) 97 | 98 | 源码来源:https://github.com/sirpdboy/luci-app-taskplan 99 | 100 | 101 | 102 | ## 使用与授权相关说明 103 | 104 | - 本人开源的所有源码,任何引用需注明本处出处,如需修改二次发布必告之本人,未经许可不得做于任何商用用途。 105 | 106 | 107 | # My other project 108 | 109 | - 路由安全看门狗 :https://github.com/sirpdboy/luci-app-watchdog 110 | - 网络速度测试 :https://github.com/sirpdboy/luci-app-netspeedtest 111 | - 计划任务插件(原定时设置) : https://github.com/sirpdboy/luci-app-taskplan 112 | - 关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice 113 | - opentopd主题 : https://github.com/sirpdboy/luci-theme-opentopd 114 | - kucat酷猫主题: https://github.com/sirpdboy/luci-theme-kucat 115 | - kucat酷猫主题设置工具: https://github.com/sirpdboy/luci-app-kucat-config 116 | - NFT版上网时间控制插件: https://github.com/sirpdboy/luci-app-timecontrol 117 | - 家长控制: https://github.com/sirpdboy/luci-theme-parentcontrol 118 | - 定时限速: https://github.com/sirpdboy/luci-app-eqosplus 119 | - 系统高级设置 : https://github.com/sirpdboy/luci-app-advanced 120 | - ddns-go动态域名: https://github.com/sirpdboy/luci-app-ddns-go 121 | - 进阶设置(系统高级设置+主题设置kucat/agron/opentopd): https://github.com/sirpdboy/luci-app-advancedplus 122 | - 网络设置向导: https://github.com/sirpdboy/luci-app-netwizard 123 | - 一键分区扩容: https://github.com/sirpdboy/luci-app-partexp 124 | - lukcy大吉: https://github.com/sirpdboy/luci-app-lukcy 125 | 126 | ## 捐助 127 | 128 | ![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明3.jpg) 129 | 130 | | 图飞了 | 图飞了 | 131 | | :-----------------: | :-------------: | 132 | |![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/支付宝.png) | ![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/微信.png) | 133 | 134 | 135 | 图飞了 136 | 137 | 138 | ## 访问数:[![](https://visitor-badge-deno.deno.dev/sirpdboy.sirpdboy.svg)][![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ) 139 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Number visits:![hello](https://views.whatilearened.today/views/github/sirpdboy/deplives.svg)[![](https://img.shields.io/badge/TGGroup-ClickJoin-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ) 2 | 3 |

4 |
Task Plan
5 |

6 | 7 |

8 | 9 | 10 | 11 | 12 |

13 | 14 | [中文](README_CN.md) | English 15 | 16 | 17 | ![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明1.jpg) 18 | 19 | Please read this page carefully, which includes precautions and instructions on how to use it. 20 | 21 | ## Function Description: 22 | 23 | ### Task Setting Version 2.3.0 (taskplan) 24 | #### 2025.10.22 Task Setting 2.3.0 Version: Fixed the issue of invalid boot service during startup 25 | 26 | ### Task Setting Version 2.2.4 (taskplan) 27 | #### 2025.8.7 Task Setting 2.2.4 Version: Fixed the issue of sometimes invalid custom scripts in the new version. 28 | 29 | ### Task Setting Version 2.2.2 (taskplan) 30 | #### 2025.4.9 Task Setting 2.2.2 Version: Fixed the issue of invalid startup tasks caused by the new version. 31 | 32 | ### Task Setting 2.2.1 Version (taskplan) 33 | #### 2025.3.19 Task Setting 2.2.1 Version: Rename luci app taskplan to differentiate from previous versions and adapt to openwrt24.10 34 | 35 | ### Timer Setting 2.0 Version 36 | #### 2023.5.23 Timer Setting 2.0 Version: a two in one version that includes scheduled task execution and boot task settings, and adds custom script functionality. 37 | 38 | ### Timer Setting Version 1.9 39 | #### 2023.4.1 Timer Setting Version 1.9: Added services such as timed network disconnection and reconnection, timed detection of WAN3 restart, etc. 40 | 41 | ### Timer setting version 1.6 42 | #### 2023.1.15 Timer Setting 1.6 Version: Refactoring and Optimizing Code Production. Added 8 new features on previous versions: timed memory cleaning, timed system garbage cleaning, timed network disconnection, timed restart of network sharing, timed redialing, etc 43 | 44 | ### Timer settings version 1.4 45 | #### 2021.2.7 Added the function of timed network restart. Now includes: timed restart, timed shutdown, timed network restart, all functions can be used together. 46 | 47 | ### Timer setting version 1.3 48 | #### On October 6, 2020, the original reset shutdown was officially renamed as timed setting, achieving the integration of timed restart and timed shutdown functions. 49 | 50 | ### Timed shutdown version 1.1 51 | #### On July 19, 2020, the timed shutdown function completely solved the problem of needing to save twice before it takes effect. 52 | 53 | ### Timed shutdown version 1.0 54 | #### On February 24, 2019, the scheduled shutdown function was first released, drawing inspiration from the open-source code of predecessors. 55 | 56 | 57 | Method for adding luci app taskplan to LEDE/OpenWRT source code. 58 | 59 | ### Method for downloading source code one: 60 | Edit the root directory of the source code folder 'feeds.comnf.defect' and add the following content: 61 | 62 | ```Brach 63 | # feeds Get source code: 64 | src-git taskplan https://github.com/sirpdboy/luci-app-taskplan 65 | ``` 66 | ```Brach 67 | # Update feeds and install themes: 68 | scripts/feeds update taskplan 69 | scripts/feeds install luci-app-taskplan 70 | ``` 71 | 72 | ### Method for downloading source code two: 73 | ```Brach 74 | # downloading 75 | git clone https://github.com/sirpdboy/luci-app-taskplan package/luci-app-taskplan 76 | make menuconfig 77 | ``` 78 | ### Configuration Menu 79 | ```Brach 80 | make menuconfig 81 | # find LuCI -> Applications, select luci-app-taskplan, save and exit 82 | ``` 83 | ### compile 84 | ```Brach 85 | # compile 86 | make package/luci-app-taskplan/compile V=s 87 | ``` 88 | 89 | ## interface 90 | 91 | ![screenshots](./doc/view.png) 92 | 93 | ![screenshots](./doc/view2.png) 94 | 95 | ![screenshots](./doc/taskplan1.png) 96 | 97 | ![screenshots](./doc/taskplan2.png) 98 | 99 | ![screenshots](./doc/taskplan3.png) 100 | 101 | 102 | Source code source:https://github.com/sirpdboy/luci-app-taskplan 103 | 104 | 105 | # My other project 106 | 107 | - Eatch Dog : https://github.com/sirpdboy/luci-app-watchdog 108 | - Net Speedtest : https://github.com/sirpdboy/luci-app-netspeedtest 109 | - Task Plan : https://github.com/sirpdboy/luci-app-taskplan 110 | - Power Off Device : https://github.com/sirpdboy/luci-app-poweroffdevice 111 | - OpentoPD Theme : https://github.com/sirpdboy/luci-theme-opentopd 112 | - Ku Cat Theme : https://github.com/sirpdboy/luci-theme-kucat 113 | - Ku Cat Theme Config : https://github.com/sirpdboy/luci-app-kucat-config 114 | - NFT Time Control : https://github.com/sirpdboy/luci-app-timecontrol 115 | - Parent Control: https://github.com/sirpdboy/luci-theme-parentcontrol 116 | - Eqos Plus: https://github.com/sirpdboy/luci-app-eqosplus 117 | - Advanced : https://github.com/sirpdboy/luci-app-advanced 118 | - ddns-go : https://github.com/sirpdboy/luci-app-ddns-go 119 | - Advanced Plus): https://github.com/sirpdboy/luci-app-advancedplus 120 | - Net Wizard: https://github.com/sirpdboy/luci-app-netwizard 121 | - Part Exp: https://github.com/sirpdboy/luci-app-partexp 122 | - Lukcy: https://github.com/sirpdboy/luci-app-lukcy 123 | 124 | ## HELP 125 | 126 | | 图飞了 | 图飞了 | 127 | | :-----------------: | :-------------: | 128 | |![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/支付宝.png) | ![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/微信.png) | 129 | 130 | 131 | no 132 | 133 | 134 | Number visits:![hello](https://visitor-badge-deno.deno.dev/sirpdboy.sirpdboy.svg)[![](https://img.shields.io/badge/TGGroup-ClickJoin-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ) 135 | -------------------------------------------------------------------------------- /luci-app-taskplan/root/etc/init.d/taskplan: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | #copyright by sirpdboy 3 | 4 | START=99 5 | STOP=10 6 | TMP=/etc/taskplan 7 | LOG=$TMP/taskplan.log 8 | TT=/etc/taskplan/taskplanrun 9 | CR=/etc/crontabs/root 10 | 11 | # 确保目录存在 12 | [ ! -d $TMP ] && mkdir -p $TMP 2>/dev/null 13 | [ ! -s $LOG ] && echo '' > $LOG 14 | 15 | run_taskplan() 16 | { 17 | [ `uci -q get taskplan.@global[0].customscript | wc -l ` > 0 ] && uci -q get taskplan.@global[0].customscript > /etc/taskplan/taskplancustomscript && sed -i 's/\r$//' /etc/taskplan/taskplancustomscript 18 | [ `uci -q get taskplan.@global[0].customscript2 | wc -l ` > 0 ] && uci -q get taskplan.@global[0].customscript2 > /etc/taskplan/taskplancustomscript2 && sed -i 's/\r$//' /etc/taskplan/taskplancustomscript2 19 | 20 | ssum=$(grep -c stime /etc/config/taskplan) 21 | lsum=$(grep -c ltime /etc/config/taskplan) 22 | 23 | for i in $(seq 0 $((ssum-1))) 24 | do 25 | enable=$(uci -q get taskplan.@stime[$i].enable ) 26 | if [ "x$enable" = "x1" ]; then 27 | month=$(uci -q get taskplan.@stime[$i].month ) || month="*" 28 | stype=$(uci -q get taskplan.@stime[$i].stype ) 29 | week=$(uci -q get taskplan.@stime[$i].week ) || week="*" 30 | minute=$(uci -q get taskplan.@stime[$i].minute ) || minute="00" 31 | hour=$(uci -q get taskplan.@stime[$i].hour ) || hour="*" 32 | [ "x$hour" = "x0" ] && hour="00" 33 | [ "x$minute" = "x0" ] && minute="00" 34 | 35 | case "$stype" in 36 | 1) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler reboot Scheduled_task" ;; 37 | 2) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler poweroff Scheduled_task" ;; 38 | 3) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler network Scheduled_task" ;; 39 | 4) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler restartsamba Scheduled_task" ;; 40 | 5) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler restartwan Scheduled_task" ;; 41 | 6) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler closewan Scheduled_task" ;; 42 | 7) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler clearmem Scheduled_task" ;; 43 | 8) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler sysfree Scheduled_task" ;; 44 | 9) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler disreconn Scheduled_task" ;; 45 | 10) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler disrereboot Scheduled_task" ;; 46 | 11) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler restartmwan3 Scheduled_task" ;; 47 | 12) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler customscript Scheduled_task" ;; 48 | 13) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler upwifi Scheduled_task" ;; 49 | 14) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler downwifi Scheduled_task" ;; 50 | 15) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler customscript2 Scheduled_task" ;; 51 | 16) cmd="$minute $hour * $month $week /usr/bin/taskplanhandler restartlan Scheduled_task" ;; 52 | esac 53 | echo "$cmd" >> $CR 54 | fi 55 | done 56 | 57 | # 清空并重新创建 taskplanrun 文件 58 | echo "#!/bin/sh" > $TT 59 | chmod +x $TT 60 | 61 | for i in $(seq 0 $((lsum-1))) 62 | do 63 | enable=$(uci -q get taskplan.@ltime[$i].enable ) 64 | if [ "x$enable" = "x1" ]; then 65 | stype=$(uci -q get taskplan.@ltime[$i].stype ) 66 | delay=$(uci -q get taskplan.@ltime[$i].delay ) || delay=10 67 | 68 | case "$stype" in 69 | 1) echo "(sleep $delay && /usr/bin/taskplanhandler reboot Startup_task) &" >>$TT ;; 70 | 2) echo "(sleep $delay && /usr/bin/taskplanhandler poweroff Startup_task) &" >>$TT ;; 71 | 3) echo "(sleep $delay && /usr/bin/taskplanhandler network Startup_task) &" >>$TT ;; 72 | 4) echo "(sleep $delay && /usr/bin/taskplanhandler restartsamba Startup_task) &" >>$TT ;; 73 | 5) echo "(sleep $delay && /usr/bin/taskplanhandler restartwan Startup_task) &" >>$TT ;; 74 | 6) echo "(sleep $delay && /usr/bin/taskplanhandler closewan Startup_task) &" >>$TT ;; 75 | 7) echo "(sleep $delay && /usr/bin/taskplanhandler clearmem Startup_task) &" >>$TT ;; 76 | 8) echo "(sleep $delay && /usr/bin/taskplanhandler sysfree Startup_task) &" >>$TT ;; 77 | 9) echo "(sleep $delay && /usr/bin/taskplanhandler disreconn Startup_task) &" >>$TT ;; 78 | 10) echo "(sleep $delay && /usr/bin/taskplanhandler disrereboot Startup_task) &" >>$TT ;; 79 | 11) echo "(sleep $delay && /usr/bin/taskplanhandler restartmwan3 Startup_task) &" >>$TT ;; 80 | 12) echo "(sleep $delay && /usr/bin/taskplanhandler customscript Startup_task) &" >>$TT ;; 81 | 13) echo "(sleep $delay && /usr/bin/taskplanhandler upwifi Startup_task) &" >>$TT ;; 82 | 14) echo "(sleep $delay && /usr/bin/taskplanhandler downwifi Startup_task) &" >>$TT ;; 83 | 15) echo "(sleep $delay && /usr/bin/taskplanhandler customscript2 Startup_task) &" >>$TT ;; 84 | 16) echo "(sleep $delay && /usr/bin/taskplanhandler restartlan Startup_task) &" >>$TT ;; 85 | esac 86 | fi 87 | done 88 | 89 | echo 'wait' >> $TT # 等待所有后台任务完成 90 | echo 'exit 0' >> $TT 91 | } 92 | 93 | start() 94 | { 95 | del_cru 96 | run_taskplan 97 | /etc/init.d/cron reload 98 | 99 | # 记录启动日志 100 | echo "$(date): taskplan started" >> $LOG 101 | } 102 | 103 | boot() 104 | { 105 | # 在启动时执行任务 106 | del_cru 107 | run_taskplan 108 | /etc/init.d/cron reload 109 | 110 | # 确保 taskplanrun 文件存在并执行 111 | if [ -f $TT ] && [ -s $TT ]; then 112 | echo "$(date): Executing taskplanrun at boot" >> $LOG 113 | bash $TT >> $LOG 2>&1 & 114 | else 115 | echo "$(date): taskplanrun file not found or empty at boot" >> $LOG 116 | fi 117 | } 118 | 119 | stop() 120 | { 121 | del_cru 122 | /etc/init.d/cron reload 123 | echo "$(date): taskplan stopped" >> $LOG 124 | } 125 | 126 | restart() 127 | { 128 | stop 129 | sleep 2 130 | start 131 | } 132 | 133 | del_cru() 134 | { 135 | sed -i '/taskplanhandler/d' $CR >/dev/null 2>&1 || true 136 | echo "#!/bin/sh" > $TT # 清空文件但保留基本结构 137 | chmod +x $TT 138 | } 139 | --------------------------------------------------------------------------------