You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash
source 'shell-core/base/trap.bash'
#Do something here
If I run it from the console, the errors will show properly; however, I want to run the script from the crontab and I would like to log the errors (complete backtrace) to the syslog. Is this possible? How?
Thanks
Best regards
Josef
The text was updated successfully, but these errors were encountered:
#!/bin/bash
#DEBUG can be:
# 0 - the errors will be logged to the syslog and printed to the console
# 1 - the errors will be printed to the console
DEBUG=0
if [ "$DEBUG" = "0" ]; then
echo -e "\n\n\n"
echo -e "\t\t\t\t\t*********************************************************"
echo -e "\t\t\t\t\tWith DEBUG=0, no colors will be displayed on the console."
echo -e "\t\t\t\t\tIf you want collors, then use DEBUG=1; however note that"
echo -e "\t\t\t\t\tnothing will be written to the syslog"
echo -e "\t\t\t\t\t*********************************************************"
echo -e "\n\n\n"
exec 1> >(logger -s -t $(basename $0)) 2>&1
fi
#This supposes that shell-core is stored in the same folder that my script
SCRIPT_FOLDER=`dirname "$0"`
source "$SCRIPT_FOLDER/shell-core/base/trap.bash"
#Do something here
I don't know how to print color when logging to the logger, but I think I can live with that.
By the way, thanks to the update of the error handling script. I found you on your post in stackoverflow
Hi
I have a script like this:
If I run it from the console, the errors will show properly; however, I want to run the script from the crontab and I would like to log the errors (complete backtrace) to the syslog. Is this possible? How?
Thanks
Best regards
Josef
The text was updated successfully, but these errors were encountered: