跳到正文
Navigation

创建计划任务(Shell 脚本、URL 请求、数据库备份等)

POST
https://your-panel.example.com:8888/crontab

创建新的计划任务。

Request body application/x-www-form-urlencoded required

  • request_time
    string
    required

    Unix 时间戳。

  • request_token
    string
    required

    按 API 概览生成的签名。

  • action
    AddCrontab
    required

    具体操作名称。

  • name
    string
    required

    任务名称

  • type
    string
    required

    周期类型

  • where1
    string
    required

    周期值(天数/分钟数等,取决于 type)

  • sType
    string
    required

    任务类型,见下表

  • sBody
    string
    required

    执行内容

  • sName
    optional
    string

    备注

  • save
    optional
    integer

    备份保留份数

  • backupTo
    optional
    string

    备份目标

Returns

default

接口响应,业务状态见下方详细说明。

JSON
  • status
    optional
    boolean

    请求结果,true 表示成功

  • msg
    optional
    string

    提示信息

各操作详细说明

AddCrontabaction=AddCrontab创建计划任务(Shell 脚本、URL 请求、数据库备份等)

创建新的计划任务。

  • 路由:POST /crontab
  • action:AddCrontab

输入参数

参数名称 必选 类型 描述
action 是 String 固定值 AddCrontab
name 是 String 任务名称
type 是 String 周期类型
where1 是 String 周期值(天数/分钟数等,取决于 type)
sType 是 String 任务类型,见下表
sBody 是 String 执行内容
sName 否 String 备注
save 否 Integer 备份保留份数
backupTo 否 String 备份目标

sType 任务类型

值 说明
toShell Shell 脚本
toUrl 访问 URL
toPython Python 脚本
database 备份数据库
site 备份网站
logs 日志切割
rememory 释放内存

type 周期类型

值 说明 where1 含义
minute-n 每 N 分钟 分钟间隔
hour 每小时 —
day 每天 —
day-n 每 N 天 天间隔
week 每周 —
month 每月 —

示例

POST /crontab HTTP/1.1
Content-Type: application/x-www-form-urlencoded

action=AddCrontab&name=测试任务&type=minute-n&where1=10&sType=toShell&sBody=echo test&sName=备注&save=0&backupTo=localhost

输出参数

参数名称 类型 描述
status Boolean 请求结果,true 表示成功
msg String 提示信息
{"status": true, "msg": "添加成功", "id": 6}

Type to search…

↑↓ navigate↵ selectEsc close