How to use Background services
Establish an rsync server on the remote host, configure the various applications of rsync on the server, and then connect the machine to a remote rsync server as a client of rsync.
Set up and configure Rsync profile/etc/rsyncd.conf on the 128 host to edit your rsyncd.conf to the following:
[Email protected] ~]# vim/etc/rsyncd.conf#/etc/rsyncd:configuration file for rsync daemon Modeport=873log File=/var/lo G/rsync.logpid file=/var/run/rsyncd.pidaddress=192.168.193.128# See rsyncd.conf Mans page for more options.# Configuration Example:[test]path=/root/rsyncread only=nolist=trueuid = Rootgid = RootUse Chroot=truemax connections= 4auth users=testsecrets file=/etc/rsyncd.passwdhosts allow=192.168.193.128
The Port,logfile,pid file,address in rscond.com is the global configuration, and the following part of [test] is the module configuration. Man rsyncd.conf can get more information.
Port: Specify on which port to start the RSYNCD service, which is port 873 by default.
Log file: Specifies the log files.
PID file: Specify the PID files, the role of this file involves the start of services, stop and other process management operations.
Address: Specifies the IP to start the RSYNCD service.
[]: Specifies the module name.
Path: Specifies the path where the data is stored.
Use Chroot True|false: Represents the first chroot to the directory specified by the path parameter before transferring the file.
Max connections: Specifies the maximum number of connections, which defaults to 0, which means there is no limit.
Read Only Ture|false: If true, you cannot upload to the path specified by the module.
List: Indicates whether the module is listed when the user queries the available modules on the server, set to True to be listed, and set to False to hide.
Uid/gid: Specifies which user/group is transferred as the file is transferred.
Auth Users: Specifies the user name to use when transferring.
Secrets file: Specifies the password files.
Hosts allow: Represents a host that is allowed to connect to the module.
Edit Secrets file and give 600 permissions after saving.
[[email protected] etc]# cat/etc/rsyncd.passwd[[email protected] etc]# vim/etc/rsyncd.passwd[[email protected] etc]# CA T/etc/rsyncd.passwdtest:test123[[email protected] etc]# chmod 600/etc/reyncd.passwdchmod: Cannot Access "/ETC/REYNCD.PASSWD": No file or directory [[email protected] etc]# chmod 600/etc/rsyncd.passwd
Linux system logs
/var/log/messages
The boot information at the start of the system will be stored in this file in the other state of the runtime.
It is implemented by the Logrotate tool, and its configuration file is/etc/logrotate.conf.
[[email protected] ~]# cat /etc/logrotate.conf# see "Man logrotate" For details# rotate log files weeklyweekly# keep 4 weeks worth of backlogsrotate 4# create new (empty) log files after rotating old onescreate# use date as a suffix of the rotated filedateext# uncomment this if you want your log files compressed#compress# rpm packages drop log rotation information into This directoryinclude /etc/logrotate.d# no packages own wtmp and btmp -- we ' ll rotate them here/var/log/wtmp { monthly create 0664 root utmp minsize 1m rotate 1}/var/log/btmp { missingok monthly create 0600 root utmp rotate 1}# System-specific logs may be also be configured here.
Man rsyslog.com See more information.
Dmesg
can display the system boot information
[[Email protected] ~]# dmesg |head[ 0.000000] initializing cgroup subsys cpuset[ 0.000000] Initializing cgroup subsys cpu[ 0.000000] initializing cgroup subsys cpuacct[ 0.000000] Linux version 3.10.0-862.el7.x86_64 ([email Protected]) (gcc version 4.8.5 20150623 (red hat 4.8.5-28) (GCC) ) #1 smp fri apr 20 16:44:24 utc 2018[ 0.000000 ] command line: boot_image=/vmlinuz-3.10.0-862.el7.x86_64 root=uuid= 23c138ca-3a70-447e-9028-e002f1d0dea9 ro crashkernel=auto rhgb quiet. utf-8[ 0.000000] disabled fast string operations[ 0.000000] e820: BIOS-provided physical RAM MAP:[    0.000000] BIOS-E820: [MEM 0X0000000000000000-0X000000000009EBFF] usable[ 0.000000] BIOS-e820: [mem 0x000000000009ec00-0x000000000009ffff] reserved[ 0.000000] bios-e820: [ Mem 0x00000000000dc000-0x00000000000fffff] reserved
Security Log
[[email protected] ~]# last |headroot pts/1 192.168.193.1 Fri Jul 20 09:08 still logged inroot pts/0 192.168.193.1 Thu Jul 19 14:32 still logged inroot pts/0 192.168.193.1 thu jul 19 08:58 - 14:31 (05:32) root pts/0 192.168.193.1 Wed Jul 18 15:46 - 21:24 (05:37) root pts/0 192.168.193.1 tue jul 17 11:11 - 18:21 (07:09) root pts/1 192.168.193.1 Mon Jul 16 18:49 - 20:41 (01:52 ) root pts/0 192.168.193.1 Mon Jul 16 18:44 - 18:49 (00:04) root pts/0 192.168.193.1 mon Jul 16 18:37 - 18:43 (00:06) root pts/1 192.168.193.1 mon jul 16 18:16 - 18:37 (00:21) root tty1 mon jul&Nbsp;16 18:14 still logged in
Xargs applications
Find files with the current directory creation time greater than 10 days, and then delete them.
[[email protected] ~]# find. Mtime +10 |xargs RM
[[email protected] ~]# mkdir test[[email protected] ~]# CD Test[[email protected] test]# touch 1.txt 2.txt 3.txt 4.txt 5.t Xt[[email protected] test]# ls1.txt 2.txt 3.txt 4.txt 5.txt[[email protected] test]# ls *.txt |xargs-n1-i{} mv {} {} _bak[[email protected] test]# ls1.txt_bak 2.txt_bak 3.txt_bak 4.txt_bak 5.txt_bak
Screen Tool Introduction
Using Nohup
First write a sleep.sh script, put it in the background to execute.
[Email protected] test]# cat/usr/local/sbin/sleep.sh! /bin/bash[[email protected] test]# nohup sh/usr/local/sbin/sleep.sh &[1] 40760
Screen tool
Screen is a window manager that can multiplex a physical terminal across multiple processes.
Install the screen command Yum install-y screen
-bash-4.2# Screen-lsthere is a screen on:40865.pts-1.aminglinux-123 (Detached) 1 Socket in/var/run/screen/s- Root.
10.32/10.33 rsync synchronizes 10.34 Linux system logs via service Screen tool