Beruflich Dokumente
Kultur Dokumente
https://unix.stackexchange.com/questions/1471...
Unix & Linux Stack Exchange works best with JavaScript enabled
sign up
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like
operating systems.. It's 100% free, no registration required.
log in
tour
help
1 2 3 15;
RUNS=0;
while open
-W /Path/to/Program.app
do
RUNS=$((RUNS+1));
echo $RUNS > /temp/autotest_run_count.txt;
done
exit 0
This script essentially runs my program (in Mac OSX) and catches any failures, otherwise it will re-run the program
when it closes.
I'd like to be able to run this like I mentioned above. Start at 10:00pm. Finish at 9:00am.
Your advice is always useful.
Thanks!
Euden
/ bash
/ shell-script
/ osx
/ time
If your OS has something like a cron daemon. Have cron start your script at what ever interval you please and also
have cron kill all running instances of your program at a slighly shifted interval. Bananguin Jul 29 at 9:47
1 Answer
I have extended your script, so that you can run it once on startup and it will do it's job between
9PM and 9AM.
#!/bin/bash -
LOGFILE="/tmp/autotest_run_count.txt"
trap "echo manual abort; exit 1"
1 2 3 15
RUNS=0
while [ 1 ] ; do
HOUR="$(date +'%H')"
if [ $HOUR -ge 21 -a $HOUR -lt 9 ] ; then
# run program
libreoffice || exit 1
RUNS=$((RUNS+9))
echo $RUNS > $LOGFILE
else
echo $RUNS, waiting H=$HOUR > $LOGFILE
# note: calculating the time till next wakeup would be more
# efficient, but would not work when the time changes abruptly
# e.g. a laptop is suspended and resumed
# so, waiting a minute is reasonably efficient and robust
1 din 2
13.12.2014 18:50
https://unix.stackexchange.com/questions/1471...
Unix & Linux Stack Exchange works best with JavaScript enabled
fi
done
2 din 2
13.12.2014 18:50