diff --git a/2024/02/20/linux-common-command/index.html b/2024/02/20/linux-common-command/index.html index cba15fc..f4d5e1e 100644 --- a/2024/02/20/linux-common-command/index.html +++ b/2024/02/20/linux-common-command/index.html @@ -27,7 +27,7 @@ - + @@ -189,7 +189,7 @@

更新于 - + @@ -214,7 +214,7 @@

Show colorful output:

Continuously print new logs

journalctl --follow --no-tail is used when you want all previous lines (better than -n 100000 or arbitrary big line count)

Restrict the output to latest run:

-

TLDR; Use the one liner: - System level:

1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`
- User level:
1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`

+

TL;DR: Use the one liner: - System level:

1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`
- User level:
1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`

Python(conda) in systemd service

Create a systemd Service File: Create a .service file (e.g., my_server.service) in a location of your choice (usually /etc/systemd/system/ for system-level services or ~/.config/systemd/user/ for user-level services). Open the file for editing.

Define the Service:

diff --git a/index.html b/index.html index ea95a57..d44d4af 100644 --- a/index.html +++ b/index.html @@ -185,7 +185,7 @@

更新于 - + @@ -211,7 +211,7 @@

Show colorful output:

Continuously print new logs

journalctl --follow --no-tail is used when you want all previous lines (better than -n 100000 or arbitrary big line count)

Restrict the output to latest run:

-

TLDR; Use the one liner: - System level:

1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`
- User level:
1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`

+

TL;DR: Use the one liner: - System level:

1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service`
- User level:
1
journalctl _SYSTEMD_INVOCATION_ID=`systemctl show -p InvocationID --value service_name.service --user`

Python(conda) in systemd service

Create a systemd Service File: Create a .service file (e.g., my_server.service) in a location of your choice (usually /etc/systemd/system/ for system-level services or ~/.config/systemd/user/ for user-level services). Open the file for editing.

Define the Service: