Skip to content

Commit c671ae5

Browse files
author
R. Diez
committed
Added "StressTrash.sh".
1 parent 862199e commit c671ae5

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

README.pod

+4
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ a given number of iterations.
273273
Helps you create simple, dummy computing tasks that run in a given number of child processes for a given number of iterations.
274274
Useful for load testing.
275275

276+
=item * B<< StressTrash.sh >>
277+
278+
Stresses the system trash (recycle bin).
279+
276280
=item * B<< build-xfce.sh >>
277281

278282
Downloads and builds Xfce from source.

StressTrash/README.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
StressTrash.sh
3+
4+
Stresses the system trash (recycle bin).

StressTrash/StressTrash.sh

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Some Linux distributions, like Ubuntu MATE 18.04.2, do not enforce any trash limits.
4+
# Sending a file to the trash bin does not release disk space.
5+
# You would expect that the system automatically deletes old trashed files
6+
# as needed, but it just does not happen on some distributions.
7+
#
8+
# This script creates and trashes files in a loop, in order to stress
9+
# the trash bin and check whether your system enforces its trash limits.
10+
#
11+
# In the case of Ubuntu MATE 18.04.2, when the disk fills up, you do get
12+
# the following dialog box:
13+
#
14+
# This computer has only x,x GB disk space remaining.
15+
#
16+
# You can free up disk space by emptying the Trash, removing unused
17+
# programs or files, or moving files to an external disk.
18+
#
19+
# However, the stress script carries on and fills up the disk
20+
# until there are no free bytes left. That is actually an undesirable
21+
# situation, because full disks tend to cause trouble everywhere.
22+
# For example, choosing the "empty trash" option in the dialog box above
23+
# does not actually work, probably because the disk is full.
24+
#
25+
# This script uses tool 'trash', so remember to install package 'trash-cli' beforehand.
26+
#
27+
# Copyright (c) 2019 R. Diez - Licensed under the GNU AGPLv3
28+
29+
set -o errexit
30+
set -o nounset
31+
set -o pipefail
32+
33+
# set -x # Enable tracing of this script.
34+
35+
declare -r EXIT_CODE_ERROR=1
36+
37+
abort ()
38+
{
39+
echo >&2 && echo "Error in script \"$0\": $*" >&2
40+
exit $EXIT_CODE_ERROR
41+
}
42+
43+
44+
# ------- Entry point -------
45+
46+
if (( $# != 0 )); then
47+
abort "Invalid number of command-line arguments."
48+
fi
49+
50+
declare -r -i FILE_SIZE_KB=$(( 1 * 1024 * 1024 ))
51+
52+
declare -i ITERATION_COUNTER=1
53+
54+
while true; do
55+
56+
printf -v FILENAME "StressTrashTestFile-%06d.bin" "$ITERATION_COUNTER"
57+
58+
echo "Creating and deleting file $FILENAME ..."
59+
60+
dd bs=1024 count="$FILE_SIZE_KB" if=/dev/urandom of="$FILENAME" status="none"
61+
62+
trash "$FILENAME"
63+
64+
ITERATION_COUNTER=$(( ITERATION_COUNTER + 1 ))
65+
66+
done

0 commit comments

Comments
 (0)