10

I am having troubles understanding how to manage recurring tasks in taskwarrior

I start with an empty database:

$ task
[task next]
No matches.

I add a recurring daily task:

$ task add recur:daily due:later test

It shows up in the report:

$ task
[task next]

ID Age Recur Due   Description Urg 
 2 -     P1D 19.2y test         2.4

1 task
Creating recurring task instance 'test'

If I mark it done like this:

$ task 2 done
Completed task 2 'test'.
Completed 1 task.
$ task
[task next]
No matches.

it disappears from the report. I believe it makes sense, since "I completed the daily task today".

The problem is it never appears again the next day and further. What am I doing wrong?

AnonymousLurker
  • 1,003
  • 1
  • 11
  • 18
  • Why are you marking it done? If it is a repeating task it is never done ... – DavidPostill Nov 25 '18 at 14:22
  • @DavidPostill what should I do then to not see it in the report till tomorrow, once I complete it today? – AnonymousLurker Nov 25 '18 at 14:33
  • 1
    Read [Taskwarrior - How Recurrence Works](https://taskwarrior.org/docs/recurrence.html) – DavidPostill Nov 25 '18 at 14:34
  • 3
    @DavidPostill I did it before resorting to ask on SE, it doesn't answer my question at all. It contains details about internal workings rather than a perspective for the end user that solves a practical problem (like mine). I fail to see where in that document is it explained how to manage recurring tasks properly – AnonymousLurker Nov 25 '18 at 14:41
  • So ask the developers. As there are no other taskwarrior questions on [su] you probably won't get an answer here. – DavidPostill Nov 25 '18 at 14:43
  • 3
    @DavidPostill this really looks like you're trying to bully me out of this site – AnonymousLurker Nov 25 '18 at 14:48
  • Not at all. I'm just advising you that there may be no other taskwarrior users on this site.. – DavidPostill Nov 25 '18 at 15:07
  • @a.t. There are only [4 answers](https://superuser.com/search?tab=newest&q=taskwarrior%20is%3aanswer) posted **before** the OP's question (1 by you which has nothing do do with taskwarrier specifically, and 2 stating they use, or will use taskwarrier). That only leaves 1 answered question. I stand by my assertion (which was posted 2 years ago). – DavidPostill Nov 15 '20 at 19:03

2 Answers2

9

I was messing around with recurring tasks and figured it out:

Some background: Creating a recurring tasks creates a parent task which spawns child tasks.
from: https://taskwarrior.org/docs/recurrence.html

with some testing, I've found that with this command:

    (ins)[>]task add "test" recur:5s due:30s
    Created task 27 (recurrence template).

Firstly, due affects the first child task. Every child task spawned after due-time (30 seconds in my example) then is due in recur-time (5 seconds in example)

    (ins)[>]task
    [task next]

    ID Age Deps P Project Recur Due  Description
    22 -                   PT5S 30s  test

    #some time later...

    (ins)[>]task
    [task next]

    ID Age Deps P Project Recur Due  Description
    22 60s                 PT5S -30s test
    23 30s                 PT5S -25s test
    24 25s                 PT5S -20s test
    25 20s                 PT5S -15s test
    26 15s                 PT5S -10s test
    27 10s                 PT5S -5s  test
    28  5s                 PT5S -    test
    29  0s                 PT5S 5s   test

However due also affects one more thing: when the second child task is spawned (the second child task is due in recur-time so the third child task spawns after recur-time and so on).

This is why you aren't seeing your second child task since you have the due date set to later which is 19.2 years time in the future according to your example; the second child task will therefore spawn only after 19.2 years time later (after which each child task will spawn daily).

user821596
  • 91
  • 1
  • 4
  • Nice! How am I supposed to "end" a recurring task? Just delete the parent task / recurrence template? – dpat Jan 26 '23 at 22:58
  • when you delete any of them it should ask you if you want to delete all of them or not: "This is a recurring task. Do you want to delete all pending recurrences of this same task? (yes/no)" – user821596 Feb 04 '23 at 22:31
4

I previously answered this same question over in unix & linux. RPosting the answer again, for record.


Before I dive into the working details, note that recurrence is not well-designed. What I bring is empirical observations and liable to change with a rework.

TLDR; How do I use and make sense of recurrence

task add recur:<duration> due:<first task due date> until:<delete first task by date> wait:<date when task will appear> "my task"

Example:

  • task add recur:daily due:9:00 until:12:00 wait:5:00 eat breakfast
  • Eat breakfast at 9:00 AM
  • Hide task until 5:00 AM
  • Remove task by lunch time
  • Create a new occurrence everyday

Details

Recurrence requires a due attribute (enforced with a validation check). Recurrence can also use until and wait attributes, if they exist. Recurrence does not use scheduled. And there is a mask attribute, that tracks which instance of the reoccurence the task is.

When a new recurring instance is created:

  • new task due = parent due + recur * mask
  • identical math for both until and wait
  • scheduled is copied wholesale from the parent task. In practice, this unexpected behaviour won't break your workflow, just affects filters and skews urgency. I call this out because it took me a very long time to discover this was not working as expected.

Every time taskwarrior runs, it checks to see if it's time to create the next occurrence. The psuedo-equation is:

now >= due + recur * (mask + 1)`

Note, there is a config value, rc.recurrence.limit, that can be used to tell taskwarrior to create even more occurrences further out.

You can expect the next occurrence to be created at the due date of the previous.