task-scheduler: rewrite with new cfgcmd syntax

This commit is contained in:
Christian Poessinger 2019-12-20 19:46:03 +01:00
parent 6580e3f987
commit 695a88c7e4
4 changed files with 30 additions and 50 deletions

View File

@ -1,6 +1,6 @@
.. _commandscripting: .. _command-scripting:
Command scripting Command Scripting
================= =================
VyOS supports executing configuration and operational commands non-interactively VyOS supports executing configuration and operational commands non-interactively

View File

@ -42,7 +42,7 @@ VyOS User Guide
high-availability high-availability
vpn/index vpn/index
load-balancing load-balancing
commandscripting command-scripting
troubleshooting troubleshooting

View File

@ -38,9 +38,9 @@ Major upgrades to the installed distribution may also require console access.
* ``57600`` - 57,600 bps * ``57600`` - 57,600 bps
* ``115200`` - 115,200 bps (default for serial console) * ``115200`` - 115,200 bps (default for serial console)
############## ###############
Network Console Network Console
############## ###############
TBD. TBD.

View File

@ -1,60 +1,40 @@
.. _task-scheduler: .. _task-scheduler:
##############
Task Scheduler
##############
Task scheduler The task scheduler allows you to execute tasks on a given schedule. It makes
-------------- use of UNIX cron_.
| Task scheduler — allows scheduled task execution. Note that scripts excecuted this way are executed as root user - this may be dangerous. .. note:: All scripts excecuted this way are executed as root user - this may
| Together with :ref:`commandscripting` this can be used for automating configuration. be dangerous. Together with :ref:`command-scripting` this can be used for
automating (re-)configuration.
.. code-block:: none .. cfgcmd:: set system task-scheduler task '<task>' interval '<interval>'
system Specify the time interval when `<task>` should be executed. The interval
task-scheduler is specified as number with one of the following suffixes:
task <name>
cron-spec <UNIX cron time spec>
executable
arguments <arguments string>
path <path to executable>
interval
<int32>[mhd]
Interval * ``none`` - Execution interval in minutes
******** * ``m`` - Execution interval in minutes
* ``h`` - Execution interval in hours
* ``d`` - Execution interval in days
You are able to set the time as an time interval. .. note:: If suffix is omitted, minutes are implied.
.. code-block:: none .. cfgcmd:: set system task-scheduler task '<task>' crontab-spec '<spec>'
set system task-scheduler task <name> interval <value><suffix> Set execution time in common cron_ time format. A cron `<spec>` of
``30 */6 * * *`` would execute the `<task>` at minute 30 past every 6th hour.
Sets the task to execute every N minutes, hours, or days. Suffixes: .. cfgcmd:: set system task-scheduler task '<task>' executable path '<path>'
* m — minutes Specify absolute `<path>` to script which will be run when `<task>` is
* h — hours executed.
* d — days
If suffix is omitted, minutes are implied. .. cfgcmd:: set system task-scheduler task '<task>' executable arguments '<args>'
Or set the execution time in common cron time. Arguments which will be passed to the executable.
.. code-block:: none .. _cron: https://en.wikipedia.org/wiki/Cron
set system task-scheduler task TEST crontab-spec "* * * 1 *"
Example
*******
.. code-block:: none
system
task-scheduler
task mytask
interval 2h
executable
path /config/scripts/mytask
arguments "arg1 arg2 arg3"
task anothertask
cron-spec "* * * 1 *"
executable
path /config/scripts/anothertask