Skip to content

Instantly share code, notes, and snippets.

@Eerovil
Created May 19, 2019 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eerovil/36d109d531659d24bfafea7111b12e90 to your computer and use it in GitHub Desktop.
Save Eerovil/36d109d531659d24bfafea7111b12e90 to your computer and use it in GitHub Desktop.
Script to run thyme and store data for each day.
#!/bin/bash -e
filename=/home/eero/Documents/thyme/`date "+%Y-%m-%d"`.json
# Backup previous original file if it contains a {
if [ -e $filename ] && grep -q { $filename; then
cp $filename "$filename".bak
else
echo "Corrupted/missing original file!"
if [ -e "$filename".bak ]; then
echo "replaced!"
cp "$filename".bak $filename
elif [ -e $filename ]; then
echo "removed"
rm $filename
else
echo "did nothing"
fi
fi
# Run thyme on orig file
/home/eero/go/bin/thyme track -o $filename
chown eero:eero $filename
chmod 664 $filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment