Bash script dosn't open in terminal on reboot
Posted
by
twigg
on Super User
See other posts from Super User
or by twigg
Published on 2012-09-11T08:03:58Z
Indexed on
2012/09/11
9:41 UTC
Read the original article
Hit count: 355
bash
Quick overview, I have created a script that reboots the laptop after x amount of time and x amount of cycles. I have added the script to the start-up applications and the script does seem to be running in the background but never opens a terminal Window. Am I missing something?
Adding Code (this is saved in a file called countdown.sh)
#!/bin/bash
# check if passed.txt exists if it does, send to soak test
if [ -f passed.txt ];
then
echo reboot has passed $nol cycles
sleep 5;
echo Starting soak tests
sleep 5;
rm testlog.txt;
rm passed.txt;
phoronix-test-suite run quick-test
exit 0;
fi
# check if file testlog.txt exists if not create it
if [ ! -f testlog.txt ];
then
echo >> testlog.txt;
fi
# read reboot file to see how many loops have been completed
exec < testlog.txt
nol=0
while read line
do
nol=`expr $nol + 1`
done
# start the countdown, x is time limit
let x=10;
while [ $x -gt 0 ];
do clear;
figlet "Rebooting in...";
figlet $x;
let x-=1;
sleep 1;
done;
echo reboot success $nol >> testlog.txt;
shutdown -r now;
# set how many times the script should shutdown the laptop
reboot_count=1
# if number of reboots matches nol's then stop the script
# create a new text file called passed.txt
if [ "$nol" == "$reboot_count" ];
then
echo reboot passed $nol cycles >> passed.txt;
fi
© Super User or respective owner