标签:存在 开机自启 通过命令 The his slice map restart disable
[root@oldboyedu run]# vim /server/scripts/rsyncd
?
?
para=$1
proc_file="/var/run/rsyncd.pid"
?
if [ "x$para" == "xstart" ]
then
if [ -f $proc_file ]
then
kill `cat /var/run/rsyncd.pid` &>/dev/null
sleep 1
rsync --daemon &>/dev/null
else
rsync --daemon &>/dev/null
fi
elif [ "x$para" == "xstop" ]
then
if [ -f $proc_file ]
then
kill `cat /var/run/rsyncd.pid` &>/dev/null
else
rsync --daemon &>/dev/null
sleep 1
kill `cat /var/run/rsyncd.pid` &>/dev/null
fi
elif [ "x$para" == "xrestart" ]
then
if [ -f $proc_file ]
then
kill `cat /var/run/rsyncd.pid` &>/dev/null
sleep 2
rsync --daemon &>/dev/null
else
rsync --daemon &>/dev/null
fi
else
echo $0 "[stop] [start] [restart]"
fi
[root@oldboyedu run]# mv /server/scripts/rsyncd /etc/init.d/
[root@oldboyedu run]# cd /etc/init.d/
[root@oldboyedu init.d]# chmod +x rsyncd
[root@oldboyedu init.d]#
?
[root@oldboyedu init.d]# vim rsyncd
?
#!/bin/bash
# chkconfig: 2345 98 99
para=$1
?
[root@oldboyedu init.d]# chkconfig --add rsyncd
[root@oldboyedu init.d]#
?
[root@oldboyedu init.d]# chkconfig --list rsyncd
rsyncd ????0:off????1:off????2:on????3:on????4:on????5:on????6:off
[root@oldboyedu init.d]#
[root@oldboyedu ~]# service rsyncd start
[root@oldboyedu ~]# service rsyncd restart
[root@oldboyedu ~]#
[root@oldboyedu scripts]# cat /server/scripts/rsyncd
#!/bin/bash
# chkconfig: 2345 98 99
proc_file="/var/run/rsyncd.pid"
?
START() {
if [ -f $proc_file ]
then
kill `cat /var/run/rsyncd.pid` &>/dev/null
sleep 1
rsync --daemon &>/dev/null
else
rsync --daemon &>/dev/null
fi
}
?
STOP() {
if [ -f $proc_file ]
then
kill `cat /var/run/rsyncd.pid` &>/dev/null
else
rsync --daemon &>/dev/null
sleep 1
kill `cat /var/run/rsyncd.pid` &>/dev/null
fi
}
?
RESTART() {
if [ -f $proc_file ]
then
kill `cat /var/run/rsyncd.pid` &>/dev/null
sleep 2
rsync --daemon &>/dev/null
else
rsync --daemon &>/dev/null
fi
}
?
OTHER() {
echo $0 "[stop] [start] [restart]"
}
?
case $1 in
start) START ;;
stop) STOP ;;
restart) RESTART ;;
*) OTHER ;;
esac
[root@oldboyedu run]# mv /server/scripts/rsyncd /etc/init.d/
[root@oldboyedu run]# cd /etc/init.d/
[root@oldboyedu init.d]# chmod +x rsyncd
[root@oldboyedu init.d]#
?
[root@oldboyedu init.d]# vim rsyncd
?
#!/bin/bash
# chkconfig: 2345 98 99
para=$1
?
[root@oldboyedu init.d]# chkconfig --add rsyncd
[root@oldboyedu init.d]#
?
[root@oldboyedu init.d]# chkconfig --list rsyncd
rsyncd ????0:off????1:off????2:on????3:on????4:on????5:on????6:off
[root@oldboyedu init.d]#
?
[root@oldboyedu scripts]# service rsyncd start
[root@oldboyedu scripts]# service rsyncd stop
[root@oldboyedu scripts]#
scp -r root@10.0.0.222:/etc/init.d/rsyncd /server/
[root@m01 server] # ls
regular rsyncd scripts
mv rsyncd /etc/init.d/
[Unit]
Description= this is a new rsync
After=network.service
?
[Service]
Type=forking
ExecStart=/bin/sh /etc/init.d/rsyncd start
ExecStop=/bin/sh /etc/init.d/rsyncd stop
ExecReload=/bin/sh /etc/init.d/rsyncd restart
?
[Install]
WantedBy=multi.user_target
[root@m01 system] # systemctl start rsyncd-new.service
[root@m01 system] # systemctl status rsyncd-new.service
● rsyncd-new.service - this is a new rsync
Loaded: loaded (/usr/lib/systemd/system/rsyncd-new.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2020-01-08 11:59:17 CST; 1s ago
Process: 4374 ExecStart=/bin/sh /etc/init.d/rsyncd start (code=exited, status=0/SUCCESS)
Main PID: 4377 (rsync)
Tasks: 1
CGroup: /system.slice/rsyncd-new.service
└─4377 rsync --daemon
?
Jan 08 11:59:17 m01 systemd[1]: Starting this is a new rsync...
Jan 08 11:59:17 m01 systemd[1]: Started this is a new rsync.
[root@m01 system] #
[root@m01 test_init] # cat para_0.sh
#!/bin/bash
sum=0
i=0
while [ $i -le 100 ]
do
((sum=sum+i))
let i++
done
echo $sum
[root@m01 test_init] # sh para_0.sh
5050
[root@m01 test_init] #
?
[root@m01 test_init] # cat para_0.sh
#!/bin/bash
sum=0
i=0
for i in `seq 100`
do
((sum=sum+i))
done
echo $sum
[root@m01 test_init] # sh para_0.sh
5050
[root@m01 test_init] #
[root@m01 test_init] # cat para_0.sh
#!/bin/bash
?
for i in {1..254}
do
{
ping -c1 -W1 10.0.0.$i &>/dev/null
if [ $? -eq 0 ]
then
echo "10.0.0.$i success"
fi
} &
done
[root@m01 test_init] # sh para_0.sh
10.0.0.1 success
10.0.0.61 success
10.0.0.222 success
10.0.0.254 success
[root@m01 test_init] #
通过命令创建一个shell环境,
[root@m01 test_init] # yum -y install screen
screen -ls????????????????????查看当前在screen存在的进程信息
screen -r????????????????????恢复当前在screen存在的进程信息
screen +a +d????????????????相当于断开窗口连接
screen +a +k????????????????相当于在screen窗口中先ctrl+c,接着ctrl+d
nmap是网络扫描工具,用来扫描网络上面的连接端,(IP/端口,域名)
nmap -sn 10.0.0.0/24????????????只做ping,不做端口扫描(n不做反向解析)
nmap 10.0.0.0/24 1-1024????????????探测10.0.0.0网段1-1024哪些端口开放的
标签:存在 开机自启 通过命令 The his slice map restart disable
原文地址:https://www.cnblogs.com/liangyuxing/p/12166085.html