8
This commit is contained in:
parent
91eb1a3de4
commit
8ee60e1fe6
111
8.html
111
8.html
@ -271,9 +271,9 @@ Alias=sshd.service
|
|||||||
|
|
||||||
<section>
|
<section>
|
||||||
<span style="color: orange">Aufgabe:</span> Erstellt eine Unit und startet sie.<p>
|
<span style="color: orange">Aufgabe:</span> Erstellt eine Unit und startet sie.<p>
|
||||||
https://wiki.archlinux.org/index.php/Systemd#Writing_unit_files
|
|
||||||
<div class="fragment">
|
<div class="fragment">
|
||||||
<code style="font-size: .5em">/etc/systemd/system/simple-webserver.service</code>
|
<code style="font-size: .5em">https://wiki.archlinux.org/index.php/Systemd#Writing_unit_files<br>/etc/systemd/system/simple-webserver.service</code>
|
||||||
<pre><code>[Unit]
|
<pre><code>[Unit]
|
||||||
Description=Simple Web Server
|
Description=Simple Web Server
|
||||||
|
|
||||||
@ -302,7 +302,8 @@ python3 -m http.server 8082 </code></pre>
|
|||||||
<pre><code>journalctl --unit=simple-webserver.service </code></pre>
|
<pre><code>journalctl --unit=simple-webserver.service </code></pre>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>Browser öffnen: <code>http://localhost:8082/BENUTZERNAME</code></section>
|
<section>Browser öffnen: <code>http://localhost:8082/BENUTZERNAME</code>
|
||||||
|
<aside class="notes">der simple webserver ist praktisch zum dateien teilen</aside></section>
|
||||||
|
|
||||||
<section><h4>Ändern der Standard-Units</h4>
|
<section><h4>Ändern der Standard-Units</h4>
|
||||||
|
|
||||||
@ -327,50 +328,41 @@ python3 -m http.server 8082 </code></pre>
|
|||||||
</aside>
|
</aside>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section style="font-size: .7em ">
|
||||||
https://wiki.archlinux.org/index.php/Systemd/Timers
|
<span style="color: orange; ">Aufgabe:</span> Erstellt einen Service, der alle 5 Minuten omikron.net pingt. Die Zeitplanung soll mit systemd timer umgesetzt werden. Die Ausgabe soll nach /var/log/omikron-ping.log geschriebne werden.<p>https://wiki.archlinux.org/index.php/Systemd/Timers
|
||||||
<aside class="notes">üben doku lesen</aside>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<span style="color: orange">Aufgabe:</span> Erstellt einen Backup Service, der per systemd Timer einmal wöchentlich läuft.
|
|
||||||
|
|
||||||
<div class="fragment">
|
<div class="fragment">
|
||||||
<code style="font-size: .5em">/etc/systemd/system/backup.timer</code>
|
<code style="font-size: .5em">/etc/systemd/system/ping-omikron.timer</code>
|
||||||
<pre><code>
|
<pre><code>
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Run backup.sh weekly
|
Description=Ping Omikron Timer
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=weekly
|
OnActiveSec=30s
|
||||||
|
OnUnitActiveSec=5m
|
||||||
Persistent=true
|
Persistent=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy=basic.target
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<code style="font-size: .5em">/etc/systemd/system/backup.service</code>
|
<code style="font-size: .5em">/etc/systemd/system/ping-omikron.service</code>
|
||||||
<pre><code>
|
<pre><code>
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Backup 2000
|
Description=Ping Omikron Unit
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/home/USERNAME-HIER-EINSETZEN/bin/backup.sh
|
ExecStart=/PFAD/ZU/ping-omikron.sh
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</section>
|
<code style="font-size: .5em">/bin/ping-omikron.sh</code>
|
||||||
|
|
||||||
<section>
|
|
||||||
<code style="font-size: .5em">~/bin/backup.sh</code>
|
|
||||||
<pre style="font-size: .4em"><code>#!/bin/bash
|
<pre style="font-size: .4em"><code>#!/bin/bash
|
||||||
tar -czf "/home/USERNAME/archiv/backup-`date +%d-%m-%Y`.tar.gz" /home/USERNAME/arbeit/
|
date &>> /var/log/ping-omikron.log
|
||||||
|
ping -c 3 oikron.net &>> /var/log/ping-omikron.log
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@ -383,20 +375,79 @@ tar -czf "/home/USERNAME/archiv/backup-`date +%d-%m-%Y`.tar.gz" /home/USERNAME/a
|
|||||||
<aside class="notes">man journalctl</aside>
|
<aside class="notes">man journalctl</aside>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section><a href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-targets">Nützliche sytemd Targets</a>
|
||||||
timedatectl
|
<p>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-targets</section>
|
||||||
<p>https://wiki.ubuntuusers.de/Systemzeit/
|
|
||||||
|
|
||||||
<p>https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-targets
|
<section>
|
||||||
|
<h4>timedatectl</h4>
|
||||||
|
Die Zeit mit systemd einstellen.
|
||||||
|
<p>https://wiki.ubuntuusers.de/Systemzeit/
|
||||||
|
<pre><code>sudo timedatectl set-timezone Europe/Berlin </code></pre>
|
||||||
|
<pre><code>sudo timedatectl set-time 2019-28-02 19:01 </code></pre>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h4>Vorteile / Nachteile zu cron:</h4>
|
||||||
|
<ul>
|
||||||
|
<li class="fragment ">Nachteil: 2 Dateien müssen angelegt werden</li>
|
||||||
|
<li class="fragment ">Vorteil: Besser steuerbar, Logs landen im systemd-journal</li>
|
||||||
|
<li class="fragment ">Das ist die Zukunft</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section style="font-size: .6em">
|
||||||
|
<p>Bemerkungen:
|
||||||
|
<p>Systemd ist rückwärtskompatibel zu Sysvinit.<br> Alte init Befehle werden von systemd verstanden, sind teilweise noch in Benutzung
|
||||||
|
<p>init-scripte sind in <code>/etc/init.d/</code> zu finden
|
||||||
|
<pre><code>sudo /etc/init.d/apache2 start </code></pre>
|
||||||
|
<p>Die logs landen weiterhin zusätzlich in /var/log/
|
||||||
|
|
||||||
|
<p>ein weiteres init-System : Upstart -> eingestellt
|
||||||
|
<aside class="notes">
|
||||||
|
cat /etc/init.d/apache2<br>
|
||||||
|
cat /lib/systemd/system/apache2.service
|
||||||
|
</aside>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
|
<section data-transition="slide" data-background="#4d7e65" data-background-transition="convex">
|
||||||
<h2>Part 7 - Startup / Shutdown</h2>
|
<h2>Part 7 - Dateisysteme</h2>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h4>Benennung von Datenträgern</h4>
|
||||||
|
<p>Festplatten / USB Sticks
|
||||||
|
<ul>
|
||||||
|
<li class="fragment ">/dev/sda - Erste Festplatte</li>
|
||||||
|
<li class="fragment ">/dev/sdb - zweite FP</li>
|
||||||
|
<li class="fragment ">/dev/sda1 - erste Partition auf erster FP</li>
|
||||||
|
<li class="fragment ">/dev/sdb2 - 2. P. auf 2. FP.</li>
|
||||||
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<p>externe Laufwerke
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li class="fragment ">/dev/scd0 od. /dev/sr0 - erstes CD / DVD Laufwerk</li>
|
||||||
|
<li class="fragment ">/dev/scd1 od. /dev/sr1 - zweites CD / DVD Laufwerk</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<section><pre><code>lsblk</code></pre>
|
||||||
|
<pre><code>NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
||||||
|
sda 8:0 0 489,1G 0 disk
|
||||||
|
├─sda1 8:1 0 63,1G 0 part /
|
||||||
|
├─sda2 8:2 0 1K 0 part
|
||||||
|
├─sda5 8:5 0 407,3G 0 part /home
|
||||||
|
├─sda6 8:6 0 9,4G 0 part [SWAP]
|
||||||
|
└─sda7 8:7 0 9,2G 0 part /tmp
|
||||||
|
sdb 8:16 0 298,1G 0 disk
|
||||||
|
└─sdb1 8:17 0 298,1G 0 part /home/dany
|
||||||
|
sr0 11:0 1 1024M 0 rom
|
||||||
|
sr1 11:1 1 1024M 0 rom
|
||||||
|
</code></pre></section>
|
||||||
|
|
||||||
|
<section>Reihenfolge kann sich beim Umstecken ändern.<br>For the rescue: UUID
|
||||||
|
<pre><code>ls -Lr /dev/disk/</code></pre></section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
6
beispiele/8/ping-omikron.service
Normal file
6
beispiele/8/ping-omikron.service
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Ping Omikron Unit
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/PFAD/ZU/ping-omikron.sh
|
3
beispiele/8/ping-omikron.sh
Normal file
3
beispiele/8/ping-omikron.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
date &>> /var/log/ping-omikron.log
|
||||||
|
ping -c 3 omikron.net &>> /var/log/ping-omikron.log
|
10
beispiele/8/ping-omikron.timer
Normal file
10
beispiele/8/ping-omikron.timer
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Ping Omikron Timer
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnActiveSec=30s
|
||||||
|
OnUnitActiveSec=5m
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
Loading…
Reference in New Issue
Block a user