Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Snippet] [Fix] Added a bash snippet #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
saminjay merged 4 commits into quicksnip-dev:main from saminjay:bash-script
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion public/icons/bash.svg
View file Open in desktop

This file was deleted.

20 changes: 20 additions & 0 deletions snippets/bash/system/kill-previous-instances.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -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
```
6 changes: 3 additions & 3 deletions snippets/bash/system/system-resource-monitor.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Loading

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /