use warnings; use strict; my $max_attempts = 5; # for windows, replace cat with type my $reboot_number = `cat reboot_attempts` || 0; if ($reboot_number++ < $max_attempts) { `echo $reboot_number > reboot_attempts`; print "Rebooting...\n"; # code to make computer reboot here }