general linux¶
kill all processes owned by a user¶
show ssl certificate (https or not)¶
# https website
openssl s_client -showcerts -servername docs.rda.run -connect docs.rda.run:443 < /dev/null
# any other tls service still works
openssl s_client -showcerts -servername tlshost.example.org -connect tlshost.example.org:49056 < /dev/null
show dell service tag¶
using a lockfile to run a script only one at a time¶
#!/bin/bash
lockfile="$0.lockfile"
if [[ -e "$lockfile" ]] && ! kill -0 "$(< "$lockfile")" 2>/dev/null; then
echo "Warning: lockfile exists but the process is dead, continuing."
rm -f "$lockfile"
elif [[ -e "$lockfile" ]]; then
echo "My important work is already running. Exiting."
exit 1
fi
printf '%s\n' "$$" > "$lockfile"
# add all your important stuff here.
rm -f "$lockfile"
exit 0
viewing crontab of all users¶
simulating the java trim()
in bash¶
reference: StackOverflow