1、新建一个同步时间的shell脚本
#!/bin/bash
PATH=$PATH:/usr/bin/:/sbin/
sudo ntpdate -u time.windows.com
sudo hwclock -w
2、将shell脚本添加到crontab
[root@localhost ~]# crontab -e
添加脚本如下:
*/5 * * * * bash /root/SyncTime.sh
扩展阅读
| f1 | f2 | f3 | f4 | f5 | program |
| 分钟 | 小时 | 月份中的第几日 | 月份 | 星期中的第几天 | 要执行的程序 |
参考文章
http://www.linuxsky.org/doc/admin/200802/247.html
本文介绍如何通过编写Shell脚本来实现每五分钟自动同步系统时间,并将该脚本加入crontab任务中进行定时执行。
1万+

被折叠的 条评论
为什么被折叠?



