25 lines
478 B
Bash
Executable File
25 lines
478 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Random Reboot after minimum uptime script
|
|
# Flat 1 in $CHANCE chance of reboot -- crontab freq matters.
|
|
# Expected per hour run
|
|
# 1000000 is one day
|
|
# chance 192 is average 8 day
|
|
|
|
MIN_UT=4000000
|
|
CHANCE=192
|
|
|
|
UPTIMEVAL=$(uptime | cut -f 2 -d ' ' | sed "s/://g")
|
|
echo "Flat uptime:$UPTIMEVAL"
|
|
|
|
#UPTIMEVAL=220000
|
|
|
|
if [[ $UPTIMEVAL -gt $MIN_UT ]] ; then
|
|
echo "gt success, now random"
|
|
if [[ $(( $RANDOM % 48 )) == 0 ]] ; then
|
|
echo "random success"
|
|
reboot
|
|
fi
|
|
fi
|
|
|