Because the seed is always the same at the startup. You can always assign a value
RANDOM=1000
to seed the RANDOM manually, perhaps with the PID
RANDOM=$$
Trying to find your seed, I wrote this small script
for ((i=-150000; i<150000 ;i=i+1)); do
RANDOM=$i;
echo "$i: $RANDOM $RANDOM $RANDOM";
done | grep "18869[^:]"
and found:
-118657: 8608 18869 19673
-108446: 18869 18855 15976
-78471: 694 18869 19296
-75678: 18869 23165 7967
-42910: 18869 27476 32727
-38285: 25548 18869 18919
-10142: 18869 31786 24719
27971: 18869 6258 29786
33149: 13707 18869 8396
60739: 18869 10568 21777
73335: 5793 18869 8019
93507: 18869 14878 13769
113521: 30647 18869 7642
126275: 18869 19188 5761
137004: 18869 3793 18604
See that this script has lots of $RANDOM
but still is fully deterministic, it'll result always the same if you call it. This link has more information about $RANDOM
and this other link has information on how to use /dev/random
and /dev/urandom
, as an alternative. Another way to generate a random number without the seed issue is to get some information about the actual time in nanoseconds.
date +%N