Skip to content

Instantly share code, notes, and snippets.

@syshack
Created April 10, 2013 08:01
Show Gist options
  • Select an option

  • Save syshack/5352702 to your computer and use it in GitHub Desktop.

Select an option

Save syshack/5352702 to your computer and use it in GitHub Desktop.
sync time every 5 minutes
#!/bin/bash -e
#Purpose:sync time every 5 minutes
rpm -qi ntpdate >/dev/null 2>&1
if [ $?!=0 ];
then yum install ntpdate >/dev/null 2>&1
if [ $?=0 ];
path=`whereis -b ntpdate|awk -F": " '{print $2}'`
then echo "*/5 * * * * root $path 10.28.167.2 >/dev/null 2>&1" >>/etc/crontab
echo "Sucess!"
fi
else echo "Failed,Please install *ntpdate* manually"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment