后台并行执行多个任务
-
方法1:多个脚本放在一个脚本内
vim f123.sh ./f1.sh & ./f2.sh & ./f3.sh &
-
方法2:小括号用;隔开
(./f1.sh&);(./f2.sh&);(./f3.sh&)
-
方法3:大括号
{ ./f1.sh& ./f2.sh& ./f3.sh& }
启动服务及关闭防火墙
以atd服务为例:
-
centos6
chkconfig --list atd 查看开机是否启动 chkconfig atd on 开机启动 service atd status 查看当前是否启动 service atd start 开启当前启动 chkconfig iptables off 防火墙关闭 runlevel 查看模式是否启动
-
centos7
systemctl is-enabled atd 查看开机是否启动 systemctl enable atd 开机启动 systemctl status atd 查看当前是否启动 systemctl start atd 开启当前启动 systemctl disable firewalld 防火墙关闭 做实验需 vim /etc/sysconfig/selinux SELINUX=disable
同步时间及自动同步时间
-
centos6
-
ntpdate 172.20.0.1 同步172.20.0.1的时间
-
vim/etc/ntp.conf 编辑文件以后自动同步
restrict default kod nomodify notrap nopeer noquery 只允许自己同步别人,如想让别人也可同步自己,需注释掉本行 server 172.20.0.1 iburst 添加172.20.0.1同步 server ntp.aliyun.com iburst 添加aliyun服务器同步,不允许别人同步不用添 把其他server iburst的同步可注释掉
-
chkconfig ntpd on 设置开机启动
-
chkconfig --list ntpd 查看是否开启
runlevel 查看运行在几上,对应上条命令 -
service ntpd status 查看服务状态
service ntpd start 开启服务
-
-
centos7
-
systemctl is-enabled chronyd 查看开机是否启动
systemctl enable chronyd 设为开机启动 -
ntpdate 172.20.0.1 先用ntpdate同步时间
-
vim /etc/chrony.conf 编辑文件方便以后自动同步
server 192.168.32.60 iburst 添加同步服务器 如允许别人同步我,去掉以下两行注释 allow 172.20.0.0/16 (注意改成服务器端网段地址) local stratum 10
-
systemctl restart chronyd 重新启动以下服务
-
chronyc sources -v 查看同步信息
-