How can I create a custom error message, without checking the return code of the last command everytime?
I want to log an event to a log file, when the script succeeded or fails (anywhere in the script). Anything like this:
# cat /var/log/myscript.log
name: myscript | state: failed | date: 2021-01-18
name: myscript | state: succeeded | date: 2021-01-19
Regards