Bash
public
Open File Limits
Share this script safely, inspect its metadata, and copy the exact command you need.
Ready to run
One-liner
curl -fsSL https://runny.sh/r/JNBPBAMH7W6E | bash
Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.763
At a glance
Script metadata
Readable before runnable
Preview
#!/usr/bin/env bash
# Open file limits
# Read-only: compares ulimit -n with /proc/self/limits. Warns if the soft limit is under 1024.
# Exit 0 if healthy, 1 if the soft limit is low, 2 if it is under 256 or unreadable.
# Hosted on Runny.sh. Review the script page before you run it.
set -u
status=0
note() { printf '%s\n' "$*"; }
bump() {
case $1 in
crit) status=2 ;;
warn) [ "$status" -lt 1 ] && status=1 ;;
esac
}
note "=== Open file limits ==="
note "Host: $(hostname 2>/dev/null || printf unknown)"
note "Pid: $$"
soft=$(ulimit -n 2>/dev/null || true)
note "ulimit -n:${soft:-unknown}"
proc_soft=""
proc_hard=""
if [ -r /proc/self/limits ]; then
note ""
awk '/^Max open files|^Limit/ {print " " $0}' /proc/self/limits
proc_soft=$(awk '/^Max open files/ {print $4}' /proc/self/limits)
proc_hard=$(awk '/^Max open files/ {print $5}' /proc/self/limits)
note "Proc soft:${proc_soft:-unknown}"
note "Proc hard:${proc_hard:-unknown}"
else
note "/proc/self/limits is not readable"
bump warn
fi
limit=${soft}
if [ -z "${limit}" ] || [ "${limit}" = "unlimited" ]; then
limit=${proc_soft:-unlimited}
fi
note ""
case "$limit" in
''|*[!0-9]*)
if [ "$limit" = "unlimited" ]; then
note " OK"
else
note " WARNING: could not parse a numeric soft limit"
bump warn
fi
;;
*)
if [ "$limit" -lt 256 ]; then
note " CRITICAL: soft nofile is under 256"
bump crit
elif [ "$limit" -lt 1024 ]; then
note " WARNING: soft nofile is under 1024"
bump warn
else
note " OK"
fi
;;
esac
note ""
case $status in
0) note "Result: HEALTHY" ;;
1) note "Result: WARNING" ;;
*) note "Result: CRITICAL" ;;
esac
exit "$status"
Raw endpointhttps://runny.sh/r/JNBPBAMH7W6E
See something unsafe?
Report this script
Tell us why it should come down. Anyone can also report a URL at /abuse.