jobber examples: exit status
The exit status is a convenient mechanism for signalling failure of a command to its parent process. jobber prints the exit status of each task. The following two examples treat the exit status of jobber itself.
- By default jobber always exits with status zero (i.e. success) and ignores failures of tasks.
- The
--fail
option causes jobber to exit immediately with exit status one (i.e. failure) if a task exits with non-zero status. - If
--soft-fail
is set the exit status of jobber is one (i.e. failure) if at least one task failed, but execution continues.
--fail
shell$cat task.list
sleep 1; echo '### this is task 1 ###'; exit 0 sleep 1; echo '### this is task 2 ###'; exit 1 sleep 1; echo '### this is task 3 ###'; exit 0 sleep 1; echo '### this is task 4 ###'; exit 1 sleep 1; echo '### this is task 5 ###'; exit 0 shell$jobber task.list init
[2022-04-04T16:36:18] appended 5 tasks shell$jobber task.list 2; echo jobber-status=$?
[2022-04-04T16:36:18] 1.1 task.worker: sleep 1; echo '### this is task 1 ###'; exit 0 ### this is task 1 ### [2022-04-04T16:36:19] 1.1 exit status: 0 [2022-04-04T16:36:19] 2.2 task.worker: sleep 1; echo '### this is task 2 ###'; exit 1 ### this is task 2 ### [2022-04-04T16:36:20] 2.2 exit status: 1 jobber-status=0 shell$jobber --fail task.list 2; echo jobber-status=$?
[2022-04-04T16:36:20] 3.3 task.worker: sleep 1; echo '### this is task 3 ###'; exit 0 ### this is task 3 ### [2022-04-04T16:36:21] 3.3 exit status: 0 [2022-04-04T16:36:21] 4.4 task.worker: sleep 1; echo '### this is task 4 ###'; exit 1 ### this is task 4 ### [2022-04-04T16:36:22] 4.4 exit status: 1 jobber-status=1 shell$jobber --fail task.list 2; echo jobber-status=$?
[2022-04-04T16:36:23] 5.5 task.worker: sleep 1; echo '### this is task 5 ###'; exit 0 ### this is task 5 ### [2022-04-04T16:36:24] 5.5 exit status: 0 jobber-status=0 shell$
--soft-fail
shell$cat task.list
sleep 1; echo '### this is task 1 ###'; exit 0 sleep 1; echo '### this is task 2 ###'; exit 1 sleep 1; echo '### this is task 3 ###'; exit 0 sleep 1; echo '### this is task 4 ###'; exit 1 sleep 1; echo '### this is task 5 ###'; exit 0 shell$jobber task.list init
[2022-04-04T16:58:27] appended 5 tasks shell$jobber task.list 3; echo jobber-status=$?
[2022-04-04T16:58:27] 1.1 task.worker: sleep 1; echo '### this is task 1 ###'; exit 0 ### this is task 1 ### [2022-04-04T16:58:28] 1.1 exit status: 0 [2022-04-04T16:58:28] 2.2 task.worker: sleep 1; echo '### this is task 2 ###'; exit 1 ### this is task 2 ### [2022-04-04T16:58:29] 2.2 exit status: 1 [2022-04-04T16:58:29] 3.3 task.worker: sleep 1; echo '### this is task 3 ###'; exit 0 ### this is task 3 ### [2022-04-04T16:58:30] 3.3 exit status: 0 jobber-status=0 shell$jobber --soft-fail task.list 3; echo jobber-status=$?
[2022-04-04T16:58:30] 4.4 task.worker: sleep 1; echo '### this is task 4 ###'; exit 1 ### this is task 4 ### [2022-04-04T16:58:31] 4.4 exit status: 1 [2022-04-04T16:58:31] 5.5 task.worker: sleep 1; echo '### this is task 5 ###'; exit 0 ### this is task 5 ### [2022-04-04T16:58:32] 5.5 exit status: 0 jobber-status=1 shell$