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 ...
随机推荐
- TortoiseGit保存用户名和密码的方法
TortoiseGit在提交或者pull时总会提示你输入用户名密码,非常麻烦,那如何解决呢? 1. 对于TortoiseGit 1.8.1.2及其后的版本,右键选择settings ——> Gi ...
- webpack-dev-server 支持其他设备访问配置
webpack-dev-server 打开的服务默认是只能localhost访问的,当有时候需要让别人访问的时候可以配置 --host 192.168.84 这样在同一个局域网下面就可以通过该ip来访 ...
- 双倍回文(bzoj 2342)
Description Input 输入分为两行,第一行为一个整数,表示字符串的长度,第二行有个连续的小写的英文字符,表示字符串的内容. Output 输出文件只有一行,即:输入数据中字符串的最长双倍 ...
- pat 甲级 1038. Recover the Smallest Number (30)
1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- [LeetCode] Populating Next Right Pointers in Each Node 深度搜索
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *nex ...
- bzoj 2844 albus就是要第一个出场 异或和出现次数 线性基
题目链接 题意 给定\(n\)个数,将其所有的子集(\(2^n\)个)的异或和按升序排列.给出一个询问\(q\),问\(q\)在该序列中第一次出现位置的下标(下标从\(1\)开始). 题解 结论 记其 ...
- bjam.exe 各个参数(转)
原文转自 http://m.blog.csdn.net/article/details?id=42265605 bjam.exe stage --toolset=msvc-12.0 --without ...
- 解决Spring在线程中注入为空指针的问题
在启用线程中使用来jdbcTemplate来查询数据库,引入jdbcTemplate是用Spring @Autowired注解 方式引入,但是在运行中 jdbcTemplate 总是 空指针 解决 ...
- hdu 4786(生成树)
Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- Codeforces 898 C.Phone Numbers-STL(map+set+vector)
C. Phone Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...