From b9db7d80ec29a1e434300d10d93db6bfa26927d7 Mon Sep 17 00:00:00 2001 From: ub1x Date: Mon, 22 Nov 2021 21:52:34 +0100 Subject: [PATCH] SaveX11crash.sh added --- README.md | 1 + SaveX11crash.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 SaveX11crash.sh diff --git a/README.md b/README.md index 9fdf8ce..fc306ed 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ See also at [LUG-VS-Wiki Nützliche Scripte](https://lug-vs.org//lugvswiki/index |[duc-index.sh](duc-index.sh)|Script to be added e.g. as cronjob, which generate an index w/o NFS and DavFS file system mounted files| |[make_exif-name.sh](make_exif-name.sh)|Add a comment in all *.jpg files in the actual and all subfolders| |[SavePC.sh](SavePC.sh)|Save some helpfull settings (not /home) and some general informatin| +|[SaveX11crash.sh](SaveX11crash.sh)|Save the X11 logs and the journalctl of the last 10 minutes| |[SchredderHDD.sh](SchredderHDD.sh)|Delete a mechanical Hard Disk (HDD) reliably to ensure before forward it to the recycling, that no old data are there| |[utf8.sh](utf8.sh)|Convert text from e.g. Windows latin1 to utf8 text (e.g. in READMEs or other text (not for office documents))| |[wmf2svg.sh](wmf2svg.sh)|Example script converts WMF files in SVG to share it easily on the internet| diff --git a/SaveX11crash.sh b/SaveX11crash.sh new file mode 100755 index 0000000..a7609b6 --- /dev/null +++ b/SaveX11crash.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# SaveX11crash.sh save the X11 logs and the journalctl of the last 10 minutes +# +# (c) GPL by Ulf Bartholomäus ub1x@gmx.net +VERSION="$( basename $0 ) Version 0.1.0 from 22.11.2021" +# +# Input: n/a +# Output: progress and 7z compressed logs +# Returnvalue: 0 if finished OK and 10 if there was an issue at 7z +# +## Verwendeten Pfad mit Datum und Uhrzeit definieren - da sich die Sekunden ändern könnten +MyPath="${HOME}/X11-Crash_$(date +%F_%H-%M-%S)" +MyTime="-10m" # -10m = die letzten 10 minuten + +## Pfad anlegen +mkdir -p ${MyPath} + +## X11 Logs in aktuellen Pfad Sichern sowie journal der letzten 10min erstellen +echo -e "Sicher X11 logs:" +cp -v /var/log/Xorg.* ${MyPath}/ +journalctl -xe --since ${MyTime} >> ${MyPath}/journalctl_${MyTime}.log +echo -e "Sicher journalctl von <${MyTime}>" + +## Packe die Logs und mache es für alle änderbar (exit falls Problem) +7za a "${MyPath}.7z" "${MyPath}" || exit 10 + +## Ordner wieder löschen und rechte auf für alle lese und schreibbar +rm -rf "${MyPath}" +chmod a+rw "${MyPath}.7z" + +## Verschiebe 7z +echo -e "Verschieb Logs in damit auch für normale Benutzer zugreifbar zu machen" +mv -v "${MyPath}.7z" /tmp