./backup.sh | poke username
Where username would accept a system user, phone number, email address, webhook url, whatever.poke username -- path/to/command arg1 arg2
The command would fork, execute the child, wait for the child to finish, then send out its notification.
This would also allow flags like:
poke --on-failure @koolba -- path/to/foo
Or even handling the child taking too long:
poke --on-lagging 20m @koolba -- path/to/something-that-might-hang
./backup.sh | ( notify-send "$(cat)" )
though that could also be written: notify-send "$(./backup.sh)"
If you also want the output in the terminal, you could use tee: ./backup.sh | tee >(notify-send "$(cat)")
If you want it to be an email or SMS, there are probably commands that you could replace notify-send with.Or sprinkle some AI on it and decide based on the destination. I wouldn't want a huge log being sent via sms but nbd for email.
Or avoid that overcomplication and specify what you want. As the one writing the command, you should know if the output is big and what the ideal is for the destination you want.
It's also a command I could throw together in about an hour with a bit of bash if I really wanted it. Mix in a bit of curl, bit of whatever the sendmail command is these days, bit of Twilio. Job's a good'un.
For the record "sprinkle some AI on it" is if statements, it was a yoke.
https://slate.com/business/2014/06/marc-andreessen-explains-...