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.

asked Feb 28, 2024 at 10:11
1
  • what resets to zero? Commented Feb 28, 2024 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
answered Feb 28, 2024 at 14:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.