10 [ "$forcedelay" -ge 1 ] && {
13 echo b
> /proc
/sysrq-trigger
# Will immediately reboot the system without syncing or unmounting your disks.
18 local period
="$1"; local forcedelay
="$2"
20 sleep "$period" && shutdown_now
"$forcedelay"
24 local period
="$1"; local forcedelay
="$2"; local pinghosts
="$3"; local pingperiod
="$4"
26 time_now
="$(cat /proc/uptime)"
27 time_now
="${time_now%%.*}"
28 time_lastcheck
="$time_now"
29 time_lastcheck_withinternet
="$time_now"
33 # account for the time ping took to return. With a ping time of 5s, ping might take more than that, so it is important to avoid even more delay.
34 time_now
="$(cat /proc/uptime)"
35 time_now
="${time_now%%.*}"
36 time_diff
="$((time_now-time_lastcheck))"
38 [ "$time_diff" -lt "$pingperiod" ] && {
39 sleep_time
="$((pingperiod-time_diff))"
43 time_now
="$(cat /proc/uptime)"
44 time_now
="${time_now%%.*}"
45 time_lastcheck
="$time_now"
47 for host in "$pinghosts"
49 if ping -c 1 "$host" &> /dev
/null
51 time_lastcheck_withinternet
="$time_now"
53 time_diff
="$((time_now-time_lastcheck_withinternet))"
54 logger
-p daemon.info
-t "watchcat[$$]" "no internet connectivity for $time_diff seconds. Reseting when reaching $period"
58 time_diff
="$((time_now-time_lastcheck_withinternet))"
59 [ "$time_diff" -ge "$period" ] && shutdown_now
"$forcedelay"
64 if [ "$mode" = "allways" ]
66 watchcat_allways
"$2" "$3"
68 watchcat_ping
"$2" "$3" "$4" "$5"