Last active
May 25, 2018 18:22
-
-
Save CristianCantoro/b36189b4e0e1b83abee3d92546010e42 to your computer and use it in GitHub Desktop.
Testing `nohup`, `&` and `disown`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# shellcheck disable=SC2128 | |
SOURCED=false && [ "$0" = "$BASH_SOURCE" ] || SOURCED=true | |
if ! $SOURCED; then | |
set -euo pipefail | |
IFS=$'\n\t' | |
fi | |
mypid="$$" | |
echo -e "[${mypid}]\\t=> I am going to launch a process" | |
./sleep.sh 90 & | |
echo -e "[${mypid}]\\t=> I have launched a process" | |
atime=60 | |
echo -e "[${mypid}]\\t=> I am goig to sleep for ${atime} s" | |
for i in $(seq 1 "${atime}"); do | |
echo -e "[${mypid}]\\t=> ${i}" | |
sleep 1 | |
done | |
echo -e "[${mypid}]\\t=> I have launched a process" | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# shellcheck disable=SC2128 | |
SOURCED=false && [ "$0" = "$BASH_SOURCE" ] || SOURCED=true | |
if ! $SOURCED; then | |
set -euo pipefail | |
IFS=$'\n\t' | |
fi | |
atime="$1" | |
mypid="$$" | |
sleep 5 | |
echo -e "[${mypid}]\\t=> I am going to sleep for ${atime} s..." | |
for i in $(seq 1 "${atime}"); do | |
echo -e "[${mypid}]\\t=> ${i}" | |
sleep 1 | |
done | |
echo -e "[${mypid}]\\t=> I have slept for ${atime} s" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment