onepub-dev/dcli

Implement a scheduler

Open

#5 opened on Nov 28, 2019

 (0 comments) (0 reactions) (0 assignees)Dart (30 forks)auto 404
enhancementhelp wanted

Repository metrics

Stars
 (266 stars)
PR merge metrics
 (PR metrics pending)

Description

I wonder if it might be nice to have a scheduler. Cron syntax is cryptic. A modern syntax might be nice. Particularly with a built support for testing that your scheduled jobs ran at the correct time and with the correct permissions. Something like

dshell schedule simulate 10:15 jobx.dart

This would run the scheduled job as if it was 10:15.

Other commands might be:

dshell schedule list

dshell schedule list <script.dart>

dshell schedule <script.dart> at 10:15

dshell schedule delete <n> - where <n> is a number output by list.
dshell schedule delete <script.dart> at 10:15
dshell schedule add <script.dart> interval 1 hour
dshell schedule add <script.dart> interval 1 hour, 30 seconds named backup
dshell schedule delete backup

The scheduled jobs would be stored in a configuration file under the ~/.dshell

Yaml would possible be a good target as it is already used in pubspec.yaml so would be familiar:

So maybe syntax like:

jobs: /path/to/exe/or/script name: backup first_run: yyyy-mm-dd hh:MM:ss re_occurs: count: 1 or forever or until: yyyy-mm-dd hh:MM:ss

interval: seconds: 10 or hours: 2

Contributor guide