Skip to content

Commit

Permalink
Site updated: 2024-02-21 23:04:38
Browse files Browse the repository at this point in the history
  • Loading branch information
Wenchi Pan committed Feb 21, 2024
1 parent c054de9 commit 4341b9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions 2024/02/20/linux-common-command/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<meta property="og:description" content="See the log from systemd service: journalctl Common usage journalctl -u UnitName --since today Use right arrow key to scroll right. Or press -S and Enter in less to toggle word wrap. Also see DigitalO">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-02-20T08:53:21.000Z">
<meta property="article:modified_time" content="2024-02-21T15:00:35.575Z">
<meta property="article:modified_time" content="2024-02-21T15:04:27.815Z">
<meta property="article:author" content="Black Pan">
<meta name="twitter:card" content="summary">

Expand Down Expand Up @@ -189,7 +189,7 @@ <h1 class="post-title" itemprop="name headline">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-02-21 23:00:35" itemprop="dateModified" datetime="2024-02-21T23:00:35+08:00">2024-02-21</time>
<time title="修改时间:2024-02-21 23:04:27" itemprop="dateModified" datetime="2024-02-21T23:04:27+08:00">2024-02-21</time>
</span>


Expand All @@ -214,7 +214,7 @@ <h2 id="show-colorful-output">Show colorful output:</h2>
<h2 id="continuously-print-new-logs">Continuously print new logs</h2>
<p><code>journalctl --follow --no-tail</code> is used when you want all previous lines (better than -n 100000 or arbitrary big line count)</p>
<h2 id="restrict-the-output-to-latest-run">Restrict the output to latest run:</h2>
<p><a target="_blank" rel="noopener" href="https://serverfault.com/questions/768901/is-there-a-way-to-make-journalctl-show-logs-from-the-last-time-foo-service-ran">TLDR</a>; Use the one liner: - System level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`</span><br></pre></td></tr></table></figure> - User level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`</span><br></pre></td></tr></table></figure></p>
<p><a target="_blank" rel="noopener" href="https://serverfault.com/questions/768901/is-there-a-way-to-make-journalctl-show-logs-from-the-last-time-foo-service-ran">TL;DR</a>: Use the one liner: - System level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`</span><br></pre></td></tr></table></figure> - User level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`</span><br></pre></td></tr></table></figure></p>
<h1 id="pythonconda-in-systemd-service">Python(conda) in systemd service</h1>
<p>Create a systemd Service File: Create a .service file (e.g., my_server.service) in a location of your choice (usually <code>/etc/systemd/system/</code> for system-level services or <code>~/.config/systemd/user/</code> for user-level services). Open the file for editing.</p>
<p>Define the Service:</p>
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ <h2 class="post-title" itemprop="name headline">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-02-21 23:00:35" itemprop="dateModified" datetime="2024-02-21T23:00:35+08:00">2024-02-21</time>
<time title="修改时间:2024-02-21 23:04:27" itemprop="dateModified" datetime="2024-02-21T23:04:27+08:00">2024-02-21</time>
</span>


Expand All @@ -211,7 +211,7 @@ <h2 id="show-colorful-output">Show colorful output:</h2>
<h2 id="continuously-print-new-logs">Continuously print new logs</h2>
<p><code>journalctl --follow --no-tail</code> is used when you want all previous lines (better than -n 100000 or arbitrary big line count)</p>
<h2 id="restrict-the-output-to-latest-run">Restrict the output to latest run:</h2>
<p><a target="_blank" rel="noopener" href="https://serverfault.com/questions/768901/is-there-a-way-to-make-journalctl-show-logs-from-the-last-time-foo-service-ran">TLDR</a>; Use the one liner: - System level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`</span><br></pre></td></tr></table></figure> - User level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`</span><br></pre></td></tr></table></figure></p>
<p><a target="_blank" rel="noopener" href="https://serverfault.com/questions/768901/is-there-a-way-to-make-journalctl-show-logs-from-the-last-time-foo-service-ran">TL;DR</a>: Use the one liner: - System level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`</span><br></pre></td></tr></table></figure> - User level: <figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`</span><br></pre></td></tr></table></figure></p>
<h1 id="pythonconda-in-systemd-service">Python(conda) in systemd service</h1>
<p>Create a systemd Service File: Create a .service file (e.g., my_server.service) in a location of your choice (usually <code>/etc/systemd/system/</code> for system-level services or <code>~/.config/systemd/user/</code> for user-level services). Open the file for editing.</p>
<p>Define the Service:</p>
Expand Down

0 comments on commit 4341b9e

Please sign in to comment.