Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This script was designed to keep time for Laptop's running *NIX systems with dead CMOS batteries
- # Specfically Mac OSX but it can be adapted to other *NIX Systems, use a launch daemon to run on osx
- # and create a .conf file named "time.conf" in /usr/share/fixes/time containing variable TIME=
- # Check out my paste for the other pieces to this script
- #Load variables from .conf file
- . /usr/share/fixes/time/time.conf
- #Variables
- DATE=$(date +%m%d%H%M%Y)
- #Check year & set time from variable in .conf file
- [ $(date +%Y) = 1969 ] && date $TIME
- #Update time via ntp server
- ntpdate -u $(systemsetup -getnetworktimeserver|awk '{print $4}')
- #Save time to variable in .conf file
- sed -i -e "s/^TIME=.*/TIME=$DATE/" /usr/share/fixes/time/time.conf
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement