Created
May 20, 2021 23:00
-
-
Save davehng/9f9d40d08b0b29ca439c6729820a7586 to your computer and use it in GitHub Desktop.
bash script to delete opensprinkler logs more than a week old
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# os wants dates in epoch time divided by 86400 (86400 = 1 day) | |
# we want to ensure that logs are only kept on the OS for a week, so get the epoch date one week ago and ask OS to delete logs for that day | |
epochdate=`date --date="1 week ago" +%s` | |
osdate=$((epochdate / 86400)) | |
echo `date`: Deleting logs for `date --date="1 week ago"`: $epochdate / 86400 = $osdate >> /home/user/sandbox/os/log.txt | |
# replace ip address and [md5hashedpassword] with your opensprinkler's details | |
curl -s "http://192.168.1.20:80/dl?pw=[md5hashedpassword]&day=$osdate" >> /home/user/sandbox/os/log.txt | |
echo >> /home/user/sandbox/os/log.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment