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 diff --git a/snippets/bash/system/kill-previous-instances.md b/snippets/bash/system/kill-previous-instances.md new file mode 100644 index 00000000..0fcafce3 --- /dev/null +++ b/snippets/bash/system/kill-previous-instances.md @@ -0,0 +1,20 @@ +--- +title: Kill Previous Instances +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 +``` 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) ``` 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