Skip to content

Instantly share code, notes, and snippets.

@linpc
Last active August 29, 2015 14:01
Show Gist options
  • Save linpc/f2b7bcb41943d51e73ad to your computer and use it in GitHub Desktop.
Save linpc/f2b7bcb41943d51e73ad to your computer and use it in GitHub Desktop.
job control in script
#!/usr/bin/env bash
set -m
sleep 100 &
echo "sleep in background..."
echo
echo "make sleep going to foreground."
echo "How about try use ^Z to make it background again ?"
echo
fg
echo "sleep done"
#!/usr/bin/env bash
# turn on monitor mode
# set -m
set -o monitor
sleep 100 &
jobs
echo "sleep in background..."
echo
echo "make sleep going to foreground."
echo "How about try use ^Z to make it background again ?"
echo
fg
jobs
# turn off monitor mode
set +o monitor
sleep 5
jobs
echo "sleep done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment