Created
August 29, 2020 04:44
-
-
Save netoht/fd6d51c62115e1efb26ac007c2707482 to your computer and use it in GitHub Desktop.
Revisions
-
netoht created this gist
Aug 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ # error handling # redirect logs so can be found in instance -> actions -> instance settings -> Get System log exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1 # trap errors. Shutdown restarts machine in an hour and prevents further commands, # so instances won't finish booting and won't report to ECS function my_trap() { echo "Sorry, there was an error at line $1 $2" && shutdown -h +60 } trap 'my_trap $${LINENO} $$? ' ERR # /error handling