shell脚本安装ntp server 服务
##############################Deploy ntp server ########################
echo "start deploy ntp server" yum install -y ntp if [ ! -f /var/log/ntpd.log ];then
touch /var/log/ntpd.log
fi chown ntp:ntp /var/log/ntpd.log cat $basepath/package/ntp.conf > /etc/ntp.conf systemctl restart ntpd
systemctl enable ntpd ntppid=`ps aux|grep ntp|grep -v "grep"|awk '{print $2}'` if [ "$ntppid" ];then
echo "success ! ntp-server is running now"
fi
通过Ansible playbook 方式安装 ntp
- hosts: 192.168.1.62
remote_user: root
tasks:
- name: Install ntp
yum:
name: ntp
state: present
tags: ntp - name: Configure ntp file
template:
src: ./ntp.conf.j2
dest: /etc/ntp.conf
- name: restart ntp
service: name=ntpd state=restarted - name: Start the ntp service
service:
name: ntpd
state: started
enabled: yes
tags: ntp
cat ntp.conf.j2 driftfile /var/lib/ntp/drift restrict 127.0.0.1
restrict -6 ::1 server 192.168.1.41 includefile /etc/ntp/crypto/pw keys /etc/ntp/keys
执行结果:
ansible-playbook ntp_setup.yml
/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.3) or chardet (2.2.1) doesn't match a supported version!
RequestsDependencyWarning) PLAY [192.168.1.62] ******************************************************************************************************************************************* TASK [Gathering Facts] ****************************************************************************************************************************************
ok: [192.168.1.62] TASK [Install ntp] ********************************************************************************************************************************************
ok: [192.168.1.62] TASK [Configure ntp file] *************************************************************************************************************************************
changed: [192.168.1.62] TASK [restart ntp] ********************************************************************************************************************************************
changed: [192.168.1.62] TASK [Start the ntp service] **********************************************************************************************************************************
ok: [192.168.1.62] PLAY RECAP ****************************************************************************************************************************************************
192.168.1.62 : ok=5 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 登录 remote host 查看 ps aux|grep ntp
ntp 27579 0.0 0.0 25720 1920 ? Ss 16:30 0:00 /usr/sbin/ntpd -u ntp:ntp -g
root 27643 0.0 0.0 112708 984 pts/0 S+ 16:30 0:00 grep --color=auto ntp
shell脚本安装ntp server 服务的更多相关文章
- SVN--下载、安装VisualSVN server 服务端和 TortoiseSVN客户端
前言: 在http://www.cnblogs.com/xiaobaihome/archive/2012/03/20/2407610.html的博客中已经很详细地介绍了SVN的服务器--VisualS ...
- shell脚本安装python、pip--这种写法是错误的---每一个命令执行完都要判断是否执行成功,否则无法进行下一步
shell脚本安装python.pip--不需要选择安装项目--不管用总报错,必须带上判断符号,while没有这种用法,写在这里为了以后少走弯路,所以不要用下面的执行了 首先把pip-.tgz 安装包 ...
- Linuxqq shell脚本安装后的卸载
官方下载和帮助页面: 传送门 linuxqq_2.0.0-b1 的时候,并没有发布 MIPS64 的 DEB 包,只能用 .sh 安装,需要手动删除卸载.愚人节发布的 beta2 新增了 MIPS64 ...
- Docker学习3-简单shell脚本安装mysql5.7与docker小技巧
前言 玩过Windows中的 .bat 的小伙伴是不是觉得很有意思呢,github中一键推送.同步拉取等等操作,哈哈,当然shell脚本也是很类似,可以运行一个脚本就可以自动给我们部署好环境啦!但是这 ...
- zabbix通过shell脚本安装异常问题定位
htxk-106主机信息现象如下: 通过zabbix_get命令 zabbix_get [7189]: Check access restrictions in Zabbix agent config ...
- shell脚本--制作自己的服务脚本
首先注意一下,我用的环境是centos6.5,中间有一些操作和在Ubuntu上有一些地方的操作是不同的, 编写脚本 首先看一个实例:假设有一个test的服务,可以通过命令对test进行启动.关闭或者重 ...
- linux可运行的shell脚本与设置开机服务启动(自己总结)
完整的ln命令参考:http://www.runoob.com/linux/linux-comm-ln.html ln :创建连接文件 - 默认创建的是硬连接,好比复制 ,但是两个文件会同步 命令:l ...
- Shell脚本自动重启Java服务
话不多说直接上代码: cd /home/javaProduct/if [ -d '/home/javaProduct/lib_new/' ]; thenecho 'Has New Lib!'echo ...
- shell 脚本安装Tomcat和java
脚本安装Tomcat和java#!/bin/bash##SCRIPT:install_jdk-8u181-linux-x64_apache-tomcat-8.0.53#AUTHOR:Shinyinfo ...
随机推荐
- POJ 2728 Desert King(最优比例生成树 二分 | Dinkelbach迭代法)
Desert King Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 25310 Accepted: 7022 Desc ...
- jquery 实践操作:attr()方法
此篇要记录的是 关于 jquery 的 attr() 方法 在JS中设置节点的属性与属性值用到setAttribute(),获得节点的属性与属性值用到getAttribute(),而在jquery中 ...
- Reactor Cooling(ZOJ 2314)
题意: 给n个点,及m根pipe,每根pipe用来流躺液体的,单向的,每时每刻每根pipe流进来的物质要等于流出去的物质,要使得m条pipe组成一个循环体,里面流躺物质. 并且满足每根pipe一定的流 ...
- Dependency Injection in ASP.NET Web API 2
What is Dependency Injection? A dependency is any object that another object requires. For example, ...
- VC6.0工程改名(转)
只讨论对工程改名,其他文件和类的名字不改变,否则就很麻烦了. 操作步骤: (1)删除 .dsw 文件.改好了会再自动生成的: (2)以写字板或记事本方式打开.dsp文件: (3)将其中所有的原工 ...
- linux多线程学习笔记五--线程安全【转】
转自:http://blog.csdn.net/kkxgx/article/details/7506085 版权声明:本文为博主原创文章,未经博主允许不得转载. 一,线程安全基础 一个函数被称为线程安 ...
- java 仓库maven
工具: apache-maven-3.2.3.zip maven_data.zip 在java Window->Preferences->Maven中 Installations中添加ap ...
- Jquery 返回json数据在IE浏览器中提示下载的问题
Jquery 返回json数据,IE浏览器提示下载的问题,当提交完数据后返回的本来是json数据的,在火弧里测试正常,解决方法如下 今天遇到Jquery 返回json数据,IE浏览器提示下载的问题,当 ...
- SDOI2017round1酱油记day0
嗯... 现在是21:12...准备睡了. 睡前写下day0一天如何过的: 早上5点起床到教室早自习,迷迷糊糊的宣誓,背东西,英语听写: 都停课了为什么还要上早自习! 我!想!去!机!房! OI才是我 ...
- jemalloc原理分析
netty4引入了内存池的概念,它的主要思想源自于jemalloc,由于难以理解netty中这一块的代码,我决定先看一看网上的相关文章 官方git jemalloc原理分析 jemalloc和内存管理 ...