From f7a5a2842422e73416bb62c565b5548c4cc92441 Mon Sep 17 00:00:00 2001 From: Saminjay Goel <32176560+saminjay@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:58:10 +0530 Subject: [PATCH 1/4] removed bash icon --- public/icons/bash.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 public/icons/bash.svg diff --git a/public/icons/bash.svg b/public/icons/bash.svg deleted file mode 100644 index 9fb1be15..00000000 --- a/public/icons/bash.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From f7be4fea09f8e00557fc7d5d20e7c68d644db611 Mon Sep 17 00:00:00 2001 From: Saminjay Goel <32176560+saminjay@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:05:25 +0530 Subject: [PATCH 2/4] fix comments of a script --- snippets/bash/system/system-resource-monitor.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/bash/system/system-resource-monitor.md b/snippets/bash/system/system-resource-monitor.md index 603c4fda..c382e5ab 100644 --- a/snippets/bash/system/system-resource-monitor.md +++ b/snippets/bash/system/system-resource-monitor.md @@ -15,8 +15,8 @@ system_resources () { system_resources "$@" -// Usage: -chmod a+x system-resource-monitor.sh // First make it executable for all the users +# Usage: +chmod a+x system-resource-monitor.sh # First make it executable for all the users -./system-resource-monitor.sh // It will print the following system resources (CPU, RAM, disk, and active users) +./system-resource-monitor.sh # It will print the following system resources (CPU, RAM, disk, and active users) ``` From 979a2eaa3db8c31ed399c90e4e6dc9c4647b1b82 Mon Sep 17 00:00:00 2001 From: Saminjay Goel <32176560+saminjay@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:06:58 +0530 Subject: [PATCH 3/4] added kill_prev snippet --- snippets/bash/system/kill-prev-session.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 snippets/bash/system/kill-prev-session.md diff --git a/snippets/bash/system/kill-prev-session.md b/snippets/bash/system/kill-prev-session.md new file mode 100644 index 00000000..cecef98a --- /dev/null +++ b/snippets/bash/system/kill-prev-session.md @@ -0,0 +1,20 @@ +--- +title: Kill Previous Instance +description: Kill all previous instances of a script +author: saminjay +tags: kill,process,background +--- + +```bash +function kill_prev() { + # $$ contains current pid (grep ignore so it doesn't suicide) + local processes + readarray -t processes < <(pgrep -f "$0" | grep -v "$$") + kill "${processes[@]}" >/dev/null 2>&1 +} + +# Usage: +# Add this function to your background running script +# It will make sure that only one instance of your script is running at a time +kill_prev +``` From a0b91a7becfb228ca9f7da754e46c1bc19f04c4d Mon Sep 17 00:00:00 2001 From: Saminjay Goel <32176560+saminjay@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:14:42 +0530 Subject: [PATCH 4/4] followed guidelines --- .../system/{kill-prev-session.md => kill-previous-instances.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename snippets/bash/system/{kill-prev-session.md => kill-previous-instances.md} (94%) diff --git a/snippets/bash/system/kill-prev-session.md b/snippets/bash/system/kill-previous-instances.md similarity index 94% rename from snippets/bash/system/kill-prev-session.md rename to snippets/bash/system/kill-previous-instances.md index cecef98a..0fcafce3 100644 --- a/snippets/bash/system/kill-prev-session.md +++ b/snippets/bash/system/kill-previous-instances.md @@ -1,5 +1,5 @@ --- -title: Kill Previous Instance +title: Kill Previous Instances description: Kill all previous instances of a script author: saminjay tags: kill,process,background pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy