I have written a Python script and scheduled it to run @reboot using cronjob. Sometimes this script throws an exception sometimes it works perfectly. I want to write test scripts for this.
Preferably, rebooting Pi 10 times and logging all the output in a log file. I have tried running a bash script, but it resets to zero after pi reboot for the first time.
-
what resets to zero?jsotola– jsotola2024年02月28日 17:56:29 +00:00Commented Feb 28, 2024 at 17:56
1 Answer 1
How are you keeping track of how many times you've booted?
You'll probably need to save the count in a file.
[[ -s boot_count ]] || echo "0" > boot_count
n=$(cat boot_count)
(( n += 1 ))
echo "$n" > boot_count
(( n < 10 )) && reboot