{"id":123,"date":"2014-01-14T17:30:14","date_gmt":"2014-01-14T16:30:14","guid":{"rendered":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/?p=123"},"modified":"2014-01-14T17:31:51","modified_gmt":"2014-01-14T16:31:51","slug":"bash-subshell-mit-logging","status":"publish","type":"post","link":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/?p=123","title":{"rendered":"Bash Subshell mit Logging"},"content":{"rendered":"<p>Eine Bash Subshell mit Umleitung der Ausgabe in eine Logdatei. Das Script \u201esubshell\u201c und \u201et.bashrc\u201d befinden sich beide im Home Verzeichnis im Unterordner \u201cbin\u201d. Das Log Verzeichniss sollte existieren und befindet sich auch im Home Verzeichnis.<\/p>\n<pre class=\"lang:default decode:true \" title=\"Bash Sub Shell with Logging\" >SHELL=\"\/bin\/bash --rcfile ~\/bin\/t.bashrc\"\r\nSUBSHELL_LOGDIR=~\/log\r\n\r\nSubShell() {\r\n  [ ! -e $SUBSHELL_LOGDIR ] &amp;&amp; mkdir -p $SUBSHELL_LOGDIR\r\n  BASHLOG=$SUBSHELL_LOGDIR\/$(date '+%Y%m%d_%H%m%S')-$$.log\r\n  clear\r\n  echo \"All Output from Shell will send to: $BASHLOG\"\r\n  echo $(date) &gt;&gt;$BASHLOG\r\n  (\r\n    # bash: no job control in this shell\r\n    exec 1&gt; &gt;(tee -a $BASHLOG) 2&gt;&amp;1\r\n    # \/bin\/bash -il\r\n    \/bin\/bash --rcfile ~\/bin\/t.bashrc -i\r\n  )\r\n  echo \"$(date '+%Y%m%d_%H%m%S') Session Closed.\" &gt;&gt;$BASHLOG\r\n}\r\n\r\n\r\n\r\n# open Subshell ...\r\nSubShell<\/pre>\n<pre class=\"lang:default decode:true \" title=\"t.bashrc\" >alias l='ls -alF --color=auto'\r\nalias la='ls -la --color=auto'\r\nalias ll='ls -l --color=auto'\r\nalias ls='ls --color=auto'\r\nalias ls-l='ls -l --color=auto'\r\n\r\nPS1='\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] '\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Eine Bash Subshell mit Umleitung der Ausgabe in eine Logdatei. Das Script \u201esubshell\u201c und \u201et.bashrc\u201d befinden sich beide im Home Verzeichnis im Unterordner \u201cbin\u201d. Das Log Verzeichniss sollte existieren und befindet sich auch im Home Verzeichnis. SHELL=&#8220;\/bin\/bash &#8211;rcfile ~\/bin\/t.bashrc&#8220; SUBSHELL_LOGDIR=~\/log &hellip; <a href=\"https:\/\/www.scheffer-online.de\/blog\/wordpress\/?p=123\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4],"tags":[],"class_list":["post-123","post","type-post","status-publish","format-standard","hentry","category-allgemein","category-linux"],"_links":{"self":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=123"}],"version-history":[{"count":3,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/123\/revisions"}],"predecessor-version":[{"id":126,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/123\/revisions\/126"}],"wp:attachment":[{"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scheffer-online.de\/blog\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}