Keeping a linux process running after I logout

The best method is to start the process in a terminal multiplexer. Alternatively you can make the process not receive the HUP signal. A terminal multiplexer provides “virtual” terminals which run independent from the “real” terminal (actually all terminals today are “virtual” but that is another topic for another day). The virtual terminal will keep … Read more

How do I sleep for a millisecond in bash or ksh

Bash has a “loadable” sleep which supports fractional seconds, and eliminates overheads of an external command: $ cd bash-3.2.48/examples/loadables $ make sleep && mv sleep sleep.so $ enable -f sleep.so sleep Then: $ which sleep /usr/bin/sleep $ builtin sleep sleep: usage: sleep seconds[.fraction] $ time (for f in `seq 1 10`; do builtin sleep 0.1; … Read more

Check if array is empty in Bash

Supposing your array is $errors, just check to see if the count of elements is zero. if [ ${#errors[@]} -eq 0 ]; then echo “No errors, hooray” else echo “Oops, something went wrong…” fi