https://github.com/hackerb9/stutter
Slow down a process to a given duty cycle
https://github.com/hackerb9/stutter
Last synced: 12 months ago
JSON representation
Slow down a process to a given duty cycle
- Host: GitHub
- URL: https://github.com/hackerb9/stutter
- Owner: hackerb9
- License: gpl-3.0
- Created: 2025-01-08T08:46:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-08T10:27:52.000Z (over 1 year ago)
- Last Synced: 2025-06-25T23:03:50.100Z (12 months ago)
- Language: Shell
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stutter
Force a process to pause its work every once in a while.
It's nicer than `nice`!
## Usage
**stutter** -p _PID_
or:
**stutter** _command_ \[ _command-arguments_ ... \]
## Examples
1. Run the 'dd' command under stutter. (^C will cancel both stutter and dd.)
```
stutter dd if=/dev/zero of=/dev/null status=progress
```
2. Cause existing process 8191 to stutter. (^C cancels stutter, not 8191.)
stutter -p 8191
## Installation
It's a shell script, so just download [stutter][rawlink], mark it executable (`chmod +x`), and move it to your bin directory (`/usr/local/bin/stutter`).
[rawlink]: https://github.com/hackerb9/stutter/raw/refs/heads/main/stutter "Download stutter shell script"
## Background
The `nice` command gives a hint to UNIX systems that certain processes should use less CPU. The Linux kernel additionally offers `ionice` and `chrt` which affect how often the process can access resources like the disk. However, those tools have often proven insufficient. Background processes which have been set as nice as possible can still interfere with high priority tasks, such as streaming video or the user interface. If you meet a processes which is needlessly impolite even after you've asked it to be nice, then this program is for you. Stutter forces a process to pause repeatedly (10 times a second by default) using UNIX signals.
This is particularly useful for background "idle" jobs launched from cron which should not interfere with interactive users. However, it has also proven handy to slow down processes for debugging issues that can normally be hard to reproduce such as timing, race conditions, and interrupt handling.
## How it works
Technically, it uses SIGSTOP/SIGCONT with a 10% active duty cycle and 0.1s period. You can adjust the on/off time by editing [the script](stutter).
```bash
# A reasonable default is to have the process active for 0.01s and
# sleep for 0.09s. (A 10% duty cycle with a period of 0.1s).
ontime=0.01
offtime=0.09
```