时间同步脚本

#!/usr/bin/env python
#coding:utf-8

#Example:
#阿里云同步
#ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
#ntpdate time.nist.gov time.nuri.net 0.asia.pool.ntp.org 1.asia.pool.ntp.org 2.asia.pool.ntp.org 3.asia.pool.ntp.org

import os
command = ['ntpdate time.nist.gov',
           'rm -rf /etc/localtime',
           'ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime',
           'hwclock -w',
           "export TZ='Asia/Shanghai'",
           'echo "export TZ=\'Asia/Shanghai\'" >> /root/.bashrc']
for com in command:
    os.system(com)  

猜你喜欢

转载自blog.51cto.com/yht1990/2133763