0

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.

1
  • what resets to zero?
    – jsotola
    Commented Feb 28 at 17:56

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.