Last active
August 29, 2015 14:01
-
-
Save cjlyth/d57d564bbf5d7af5cba5 to your computer and use it in GitHub Desktop.
Snippet to redirect stderr and stdout to a file for a script
This file contains 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 characters
#!/usr/bin/env bash | |
find /tmp -maxdepth 1 -type f -uid $(id -u) -name "*err*.log" -delete |
This file contains 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 characters
#!/usr/bin/env bash | |
find /tmp -maxdepth 1 -type f -uid $(id -u) -name "*err*.log" | sort |
This file contains 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 characters
#!/usr/bin/env bash | |
# see http://www.tldp.org/LDP/abs/html/x17974.html | |
log_name="${log_name:-$(basename ${0%.*})}" | |
log_file="$(mktemp -u -t ${log_name:-script}-err-XXXXXXXXXX --suffix=.log)" | |
exec 2> ${log_file} | |
echo "Redirecting errors to ${log_file}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment