1. Use of time-related random numbers
Generate output Unixtimestamp (%s) and current time nanosecond data (%N, accurate to one-seconds) using the data command. )
The former ensures that the output does not repeat in different seconds, and that the number does not repeat in the same second and that the combination is possible.
Copy Code code as follows:
This method does not rely on the system as long as the time does not stop, it can always get a random number without repetition
2. System Shell Internal variable $RANDOM
So there's nothing to say about relying on the shell
3. Obtain and then calculate checksum via Linux's random device
Copy Code code as follows:
Head-10/dev/urandom | Cksum
Note that there is no use of cat to get this is an endless road to get 1 rows and 10 lines There's not much difference between this
4. Through the kernel of the Linux UUID access
The data of the UUID will be added to the hardware, time, and the current running information of the machine, which can guarantee the generation of the world's only direct
Copy Code code as follows:
Cat/proc/sys/kernel/random/uuid
You can then convert the checksum to the number, but rely on the Linux kernel.
4 kinds of ideas for your own reference.