Skip to content

Instantly share code, notes, and snippets.

@yannispanousis
Created September 4, 2015 12:32
Show Gist options
  • Save yannispanousis/d4093ba0f6d6c51b0b10 to your computer and use it in GitHub Desktop.
Save yannispanousis/d4093ba0f6d6c51b0b10 to your computer and use it in GitHub Desktop.
Sync NTP Time Background Process
#!/bin/bash
#
# Run me like this: "sudo bash sync-time.sh"
#
PID=/var/run/sync-time.pid
GREP=$(ps aux | grep $PID)
GREP_RC=$?
if [[ -f $PID && $GREP_RC == 0 ]]; then
echo "Process already running"
exit 0
fi
while true; do sudo ntpclient -s -h 83.231.183.4; sleep 30; done &> /dev/null &
echo "$!" > $PID
disown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment