Search This Blog

Wednesday, August 21, 2013

Check blackout length (for BeagleBone Black)

timer.sh:
root@beaglebone:~/Desktop# cat timer.sh

#!/bin/bash

KEEPALIVE=/home/root/Desktop/log.txt
#TARGET=/home/root/Desktop/log_$(date -r $SOURCE +"%Y-%m-%d_%H-%M-%S").txt
TARGET=/home/root/Desktop/log_$(date -d "today" +"%Y-%m-%d_%H-%M-%S").txt
BOOT=/home/root/Desktop/boot.txt


# se esiste bootfile salva log.txt con ora corrente
if [ -e $BOOT ]
then
echo "$BOOT exist"
mv $KEEPALIVE $TARGET
rm $BOOT
fi

echo $(date -d "today" +"%Y-%m-%d %H:%M:%S") > $KEEPALIVE

timerboot.sh:
root@beaglebone:~/Desktop# cat timerboot.sh

#!/bin/bash

TARGET=/home/root/Desktop/boot.txt

echo "boot" > $TARGET

crontab:
root@beaglebone:~/Desktop# crontab -l

30 * * * *    /usr/bin/ntpdate-sync silent
*/5 * * * * /home/root/Desktop/timer.sh
@reboot /home/root/Desktop/timerboot.sh