Bash scripting, checking for errors, logging

后端 未结 4 1062
萌比男神i
萌比男神i 2021-02-03 13:43

Here\'s one for the bash-fu wizards. No, actually, I\'m just kidding, you\'ll all probably know this except for me..

I\'m trying to create a backup shell script. The ide

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-03 14:18

    The easy way out, but with no explicit error message add -e to the shebang, i.e. #!/bin/sh -e which will cause the shell to exit if a command fails..

    Cron should give you an error message through the mail I guess though.

    If you want to go full blown back-up scheme though, I'd suggest you use something that has already been made. There are a bunch out there, and most work very well.

提交回复
热议问题