aboutsummaryrefslogtreecommitdiff
path: root/bin/nicely
diff options
context:
space:
mode:
Diffstat (limited to 'bin/nicely')
-rwxr-xr-xbin/nicely67
1 files changed, 67 insertions, 0 deletions
diff --git a/bin/nicely b/bin/nicely
new file mode 100755
index 0000000..d062f02
--- /dev/null
+++ b/bin/nicely
@@ -0,0 +1,67 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ nicely COMMAND...
+ nicely -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+
+ Options:
+ -h, --help show this message
+
+ COMMAND the command to be wrapped
+
+
+ Wrap COMMAND in nice(1) and ionice(1) calls, so that it gets low
+ priority from the OS scheduler and has low disturbance regarding
+ CPU usage and disk IO bandwidth.
+
+
+ Examples:
+
+ Make the backup low priority:
+
+ $ nicely backup
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ (--)
+ break
+ ;;
+ (--help)
+ usage
+ help
+ exit
+ ;;
+ (*)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ (h)
+ usage
+ help
+ exit
+ ;;
+ (*)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+ionice -c3 nice -n19 "$@"