Originally published December 19, 2018 @ 5:41 pm

Admittedly, this has a limited range of practical applications and is more of a scripting exercise. The command shown here generates a bunch of temporary scripts each containing the sleep command for up to one minute.

The scripts are ran in the background and upon exit will delete themselves. The number of processes will be limited to one-tenth on the maximum number of processes allowed by the kernel on your server.

(( x = $(grep -m1 [0-9] /proc/sys/kernel/pid_max) / 10 )) 
for i in $(seq 1 ${x}); do 
f=$(mktemp)
chmod 700 ${f} cat << EOF > ${f} 
#!/bin/bash 
sleep $(expr $RANDOM % 61) 
rm -- "\
(( x = $(grep -m1 [0-9] /proc/sys/kernel/pid_max) / 10 )) 
for i in $(seq 1 ${x}); do 
f=$(mktemp)
chmod 700 ${f} cat << EOF > ${f} 
#!/bin/bash 
sleep $(expr $RANDOM % 61) 
rm -- "\$0" 
EOF 
( ${f} & ); done
" EOF ( ${f} & ); done