jobber examples: repeating tasks
jobber can repeat tasks that were already executed. The example shows how all tasks that failed, i.e. that ended with non-zero exit status, can be repeated:
- The
retry
action puts all failed tasks back into the queue. - The
print:queued
action is employed to show the task queue. The queue is empty beforeretry
an contains the tasks that failed afterwards.
shell$cat task.list
sleep 1; echo '--task-1--'; exit 0 sleep 1; echo '--task-2--'; exit 1 sleep 1; echo '--task-3--'; exit 0 sleep 1; echo '--task-4--'; exit 1 sleep 1; echo '--task-5--'; exit 0 sleep 1; echo '--task-6--'; exit 1 sleep 1; echo '--task-7--'; exit 0 sleep 1; echo '--task-8--'; exit 1 shell$jobber task.list init
[2022-04-06T12:12:01] appended 8 tasks shell$jobber task.list 8
[2022-04-06T12:12:01] 1.1 task.worker: sleep 1; echo '--task-1--'; exit 0 --task-1-- [2022-04-06T12:12:02] 1.1 exit status: 0 [2022-04-06T12:12:02] 2.2 task.worker: sleep 1; echo '--task-2--'; exit 1 --task-2-- [2022-04-06T12:12:03] 2.2 exit status: 1 [2022-04-06T12:12:03] 3.3 task.worker: sleep 1; echo '--task-3--'; exit 0 --task-3-- [2022-04-06T12:12:04] 3.3 exit status: 0 [2022-04-06T12:12:04] 4.4 task.worker: sleep 1; echo '--task-4--'; exit 1 --task-4-- [2022-04-06T12:12:05] 4.4 exit status: 1 [2022-04-06T12:12:05] 5.5 task.worker: sleep 1; echo '--task-5--'; exit 0 --task-5-- [2022-04-06T12:12:06] 5.5 exit status: 0 [2022-04-06T12:12:06] 6.6 task.worker: sleep 1; echo '--task-6--'; exit 1 --task-6-- [2022-04-06T12:12:07] 6.6 exit status: 1 [2022-04-06T12:12:07] 7.7 task.worker: sleep 1; echo '--task-7--'; exit 0 --task-7-- [2022-04-06T12:12:08] 7.7 exit status: 0 [2022-04-06T12:12:08] 8.8 task.worker: sleep 1; echo '--task-8--'; exit 1 --task-8-- [2022-04-06T12:12:09] 8.8 exit status: 1 shell$jobber task.list print:queued
#!/bin/bash shell$jobber task.list retry
[2022-04-06T12:12:09] tasks changed to state Q: 4 shell$jobber task.list print:queued
#!/bin/bash # task 2 worker 2 queued sleep 1; echo '--task-2--'; exit 1 # task 4 worker 4 queued sleep 1; echo '--task-4--'; exit 1 # task 6 worker 6 queued sleep 1; echo '--task-6--'; exit 1 # task 8 worker 8 queued sleep 1; echo '--task-8--'; exit 1 shell$