How to keep up the consistent progress of the console utilities?

There is data that I process is consistently console tools (written by me). Accordingly, they accept the input data in the form of files and give the files that are processed further. The task is resource intensive and takes time.
How to monitor the progress of work and to support the launch of previous successfully completed step in the event of incorrect completion of the current?
Now I'm just looking that the files exist in the output. If there is, then this stage is completed successfully and you can skip. But maybe there's a technique for such problems? System: Linux (Ubuntu).
July 8th 19 at 16:15
2 answers
July 8th 19 at 16:17
a simple option with the addition of the status function:
#!/usr/bin/bash
set-o history

status(){
 STATUS=$?; COMMAND=$(history 2 |head -n1 |awk '{$1="";print}')
 if [[ $STATUS == 0 ]]
 then echo -e "[ OK ]\t$COMMAND"
 else echo -e "[ ERROR ]\t$COMMAND"
 exit # on error, stop processing the script
fi
}

touch a1.txt
status

rm a1.txt
status

rm a1.txt
status


the output in the console get:
[ OK ] touch a1.txt
[ OK ] rm a1.txt
rm: cannot remove 'a1.txt': No such file or directory
[ ERROR ] rm a1.txt


if you want it all, you can log to a file
July 8th 19 at 16:19

How to monitor the progress of work and to support the launch of previous successfully completed step in the event of incorrect completion of the current?

You have right in your scripts should be completed with the code. If no errors, you need to terminate the script using exit 0. If an error occurred, you need to terminate the script using exit 1.
When you have a script made so you can check them exit code.

And then you can write script with strings
{ script1.sh && echo "script1 ok"; } || echo "script1 - fail"
{ script2.sh && echo "script2 - ok"; } || echo "script2 - fail"
{ script3.sh && echo "script3 - ok"; } || echo "script3 - fail"


Example
{ echo x1 && echo "script1 ok"; } || echo "script1 - fail"
{ cat x && echo "script2 - ok"; } || echo "script2 - fail"
{ echo x2 && echo "script3 - ok"; } || echo "script3 - fail"
{ touch /x && echo "script4 - ok"; } || echo "script4 - fail"


[guest@localhost ~]$ { echo x1 && echo "script1 ok"; } || echo "script1 - fail"
x1
script1 - ok
[guest@localhost ~]$ { cat x && echo "script2 - ok"; } || echo "script2 - fail"
cat: x: No such file or directory
script2 - fail
[guest@localhost ~]$ { echo x2 && echo "script3 - ok"; } || echo "script3 - fail"
x2
script3 - ok
[guest@localhost ~]$ { touch /x && echo "script4 - ok"; } || echo "script4 - fail"
touch: cannot run touch "/x": access is Denied
script4 - fail
[guest@localhost ~]$



You could do that
{ script1.sh && echo "script1 ok"; } || { echo "script1 - fail"; exit 1; }
{ script2.sh && echo "script2 - ok"; } || { echo "script2 - fail"; exit 1; }

He then in case of success will output the successful phrase and continue, as in the case of an error it will output the failed phrase and immediately exit (with error code).

Find more questions by tags LinuxProgrammingMonitoringTerminal