You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"description": "Kill all previous instances of a script",
8
-
"author": "saminjay",
9
-
"tags": [
10
-
"kill",
11
-
"process",
12
-
"background"
13
-
],
14
-
"contributors": [],
15
-
"code": "function kill_prev() {\n # $$ contains current pid (grep ignore so it doesn't suicide)\n local processes\n readarray -t processes < <(pgrep -f \"$0\" | grep -v \"$$\")\n kill \"${processes[@]}\" >/dev/null 2>&1\n}\n\n# Usage:\n# Add this function to your background running script\n# It will make sure that only one instance of your script is running at a time\nkill_prev\n",
16
-
"extension": "bash"
17
-
},
18
-
{
19
-
"title": "System Resource Monitor",
20
-
"description": "Monitors system resources (CPU, RAM, disk, users)",
21
-
"author": "sponkurtus2",
22
-
"tags": [
23
-
"file",
24
-
"system"
25
-
],
26
-
"contributors": [],
27
-
"code": "system_resources () {\n echo \"CPU Load: $(top -bn1 | grep \"Cpu(s)\" | awk '{print $2}')%\"\n echo \"Memory Used: $(free -m | awk 'NR==2{printf \"%.2f%%\", $3*100/$2}')\"\n echo \"Disk Used: $(df -h / | awk 'NR==2{print $5}')\"\n echo \"Active Users: $(who | wc -l)\"\n}\n\nsystem_resources \"$@\"\n\n# Usage:\nchmod a+x system-resource-monitor.sh # First make it executable for all the users\n\n./system-resource-monitor.sh # It will print the following system resources (CPU, RAM, disk, and active users)\n",
28
-
"extension": "bash"
29
-
}
30
-
]
31
-
}
32
-
]
2
+
{
3
+
"name": "System",
4
+
"snippets": [
5
+
{
6
+
"title": "Kill Previous Instances",
7
+
"description": "Kill all previous instances of a script",
8
+
"author": "saminjay",
9
+
"tags": ["kill", "process", "background"],
10
+
"contributors": [],
11
+
"code": "function kill_prev() {\n # $$ contains current pid (grep ignore so it doesn't suicide)\n local processes\n readarray -t processes < <(pgrep -f \"$0\" | grep -v \"$$\")\n kill \"${processes[@]}\" >/dev/null 2>&1\n}\n\n# Usage:\n# Add this function to your background running script\n# It will make sure that only one instance of your script is running at a time\nkill_prev\n",
12
+
"extension": "bash"
13
+
},
14
+
{
15
+
"title": "System Resource Monitor",
16
+
"description": "Monitors system resources (CPU, RAM, disk, users)",
17
+
"author": "sponkurtus2",
18
+
"tags": ["file", "system"],
19
+
"contributors": [],
20
+
"code": "system_resources () {\n echo \"CPU Load: $(top -bn1 | grep \"Cpu(s)\" | awk '{print $2}')%\"\n echo \"Memory Used: $(free -m | awk 'NR==2{printf \"%.2f%%\", $3*100/$2}')\"\n echo \"Disk Used: $(df -h / | awk 'NR==2{print $5}')\"\n echo \"Active Users: $(who | wc -l)\"\n}\n\nsystem_resources \"$@\"\n\n# Usage:\nchmod a+x system-resource-monitor.sh # First make it executable for all the users\n\n./system-resource-monitor.sh # It will print the following system resources (CPU, RAM, disk, and active users)\n",
0 commit comments