Editing
Log vanuit script
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
= Uitgebreid loggen vanuit script = Binnen Webhuis zijn vele scripts in gebruik die allerdaagse taken uitvoeren. Logging vanuit scripts zorgt ervoor dat het verloop van het proces in die scripts in de syslog en daarmee eveneens in de log van de centrale syslog-ng server terecht komt. Voeg in de eerste van het script met logging toe: <pre> #!/bin/bash export script_name="naam-van-het-script" . /usr/local/bin/logging.sh ${script_name} </pre> == logging.sh == Het logging script verzorgt de gestandaardiseerde aansturing van het loggen vanuit het aanroepende script. <pre> #!/bin/bash # Uitgebracht onder GPL2 # http://webhuis.nl/index.php?option=com_docman&task=doc_download&gid=8&Itemid=54 #<----->functie voor het getandaardiseerd loggen vanuit aanroepende scripts #<----->Het aanroepende script "sourced" het logging script" LOG_FACILITY="local7.notice" LOG_ERR="local7.err" LOG_TOPIC=${script_name} LOG_TOPIC_OUT="$LOG_TOPIC-out[$$]" LOG_TOPIC_ERR="$LOG_TOPIC-err[$$]" exec 3>&1 > >(tee -a /dev/fd/3 | logger -p "$LOG_FACILITY" -t "$LOG_TOPIC_OUT" ) exec 2> >(logger -p "$LOG_ERR" -t "$LOG_TOPIC_ERR" ) </pre> == Uitvoer in de log == De uitvoer bevat een geprovoceerde foutmelding - rm van een niet bestaand bestand - en een uitvoermelding. <pre> Feb 8 21:33:45 Webhuis-server naam-van-het-script-err[18573]: rm: cannot remove `/var/aap/noot/mies': No such file or directory Feb 8 21:33:45 Webhuis-server naam-van-het-script-out[18573]: /usr/local/bin </pre> <hr/> Terug naar: [[Webhuis Support Infrastructuur]]
Summary:
Please note that all contributions to Webhuis wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see
Project:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Voorpagina
Cobol and PostgreSQL
PostgreSQL
CFEngine
Proxmox
Webhuis Kennisbank
Basale infra
Webhuis bouwstenen
Webhuis configuratie
Webhuis Infra
Webhuis Support
Webhuis Raspberry
Opzet Applicaties
Business Applicaties
Community portal
Current events
Recent changes
Random page
Help
sitesupport
Tools
What links here
Related changes
Special pages
Page information