Async Task

“Task” is not about “asynchronous processing”.
“Task” is just a task and it is a structure that someone will process the task.
An asynchronous method is a Task (work procedure manual) created by combining Tasks.
Async void absolute use prohibited(except: UI event handler)

The concept of Task.Run is in a nutshell.
“We consider synchronous series of processing as one task”
If combining asynchronous tasks and combining them into one task is an asynchronous method, you may also want to include synchronous processing as one of the tasks. At that time, it is Task.Run that can be used.

Another use is to write an asynchronous lambda expression in Task.Run. This is just like calling the asynchronous method. The only difference from direct call is that “th asynchronous method is explicitly executed in another context.”


rsync is application software that uses differential encoding to minimize the amount of data transfer and synchronize files and directories between remote site in UNIX sytems. As a unique feature of rsync which is not found in similar programs and protocols, there is a point that transfer with a mirror site is done bidirectionally at most once. rsync displays directory contents and can copy directories and files. Optionally data compression and recursion can also be specified.

The rsync protocol daemon rsyncd uses TCP port number 873 by default. rsync can also be used to synchronize local directories, it can also be used via RSH or SSH remote shell. In the latter case, the rsync client program needs to be installed both locally and remotely.

It is released at GNU General Public License and is free software.

[vagrant@localhost ~]$ sudo lsyncd -nodaemon -log scarce /etc/lsyncd.conf
Error: failure getting absolute path of [/tmp/origin]
Error: Cannot access source directory: /tmp/origin
[vagrant@localhost ~]$ sudo lsyncd -nodaemon -log scarce /etc/lsyncd.conf

what is xinetd?

xinetd is an Internet super server replacing the inetd daemon. For inetd, the setting of the service to be provided was done in /etc/intd.conf, but in xinetd, setting of services to be provided using /etc/xinetd.conf and files under /etc/xinetd.d to hold.

/etc/xinetd.conf is the default configuration file of xinetd, and each file under /etc/xinetd.d is a configuration file for each service.

[vagrant@localhost ~]$ sudo cat /etc/xinetd.conf
cat: /etc/xinetd.conf: そのようなファイルやディレクトリはありません


edit /etc/lsyncd.conf

default file setting

-- User configuration file for lsyncd.
-- Simple example for default rsync, but executing moves through on the target.
-- For more examples, see /usr/share/doc/lsyncd*/examples/
-- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}

[vagrant@localhost ~]$ sudo vi /etc/lsyncd.conf

settings {
	logfile = "/var/log/lsyncd/lsyncd.log",
	statusFile = "/var/log/lsyncd/lsyncd.status"

sync {
	source = "/tmp/origin",
	target = "/tmp/target",
	rsync = {
		archive = true,
		compress = true
	delete = false

[vagrant@localhost ~]$ mkdir -m 700 /var/log/lsyncd && chcon -R -u system_u “/var/log/lsyncd”
mkdir: ディレクトリ `/var/log/lsyncd’ を作成できません: ファイルが存在します

[vagrant@localhost ~]$ systemctl restart rsyslog
-bash: systemctl: コマンドが見つかりません
[vagrant@localhost ~]$ systemctl start lsyncd
-bash: systemctl: コマンドが見つかりません


cp -ip ${file_name}

-i option: to confirm when overwriting is necessary
In contrast to the -f option, sometimes you want to check whether it will be overwritten. When dealing with important files, overwriting is a fatal injury.

$cp -i after original copy

“yes or no” confirmation will come out.

cp -i

In recent distributions this is the default as well. If it is not set it may be set with alias.

-p opiton(-parents): copy each directory structure
With the usual cp command, you can not copy in subdirectories. In that case, use the “-P” option.

Running without options in the example will normally just let file.txt go into the directory. Using the –parents option you will find that you can copy the directory structure as is.

[vagrant@localhost ~]$ cp -ip /etc/lsyncd.conf{,.org}
cp: cannot create regular file `/etc/’: 許可がありません
[vagrant@localhost ~]$ sudo cp -ip /etc/lsyncd.conf{,.org}

install Lsyncd on CentOS

Introduction of Extra Packages for Enterprise Linux (EPEL).


name=Extra Packages for Enterprise Linux 6 - $basearch

name=Extra Packages for Enterprise Linux 6 - $basearch - Debug

name=Extra Packages for Enterprise Linux 6 - $basearch - Source

[vagrant@localhost ~]$ sudo sed -i -e “s/enabled=1/enabled=0/” /etc/yum.repos.d/epel.repo

[vagrant@localhost ~]$ sudo yum –enablerepo=epel install lsyncd
Determining fastest mirrors
epel/metalink | 7.6 kB 00:00
* base:
* epel:
* extras:
* remi-safe:
* updates:
base | 3.7 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:12
extras | 3.4 kB 00:00
jenkins | 2.9 kB 00:00
jenkins/primary_db | 126 kB 00:01
mariadb | 2.9 kB 00:00
mysql-connectors-community | 2.5 kB 00:00
mysql-tools-community | 2.5 kB 00:00
mysql56-community | 2.5 kB 00:00
nginx | 2.9 kB 00:00
nodesource | 2.5 kB 00:00
remi-safe | 3.0 kB 00:00
remi-safe/primary_db | 1.2 MB 00:02
updates | 3.4 kB 00:00
–> トランザクションの確認を実行しています。
—> Package lsyncd.x86_64 0:2.1.5-0.el6 will be インストール
–> 依存性解決を終了しました。


パッケージ アーキテクチャ バージョン リポジトリー 容量
lsyncd x86_64 2.1.5-0.el6 epel 73 k

インストール 1 パッケージ

総ダウンロード容量: 73 k
インストール済み容量: 205 k
これでいいですか? [y/N]y
lsyncd-2.1.5-0.el6.x86_64.rpm | 73 kB 00:00
rpm_check_debug を実行しています
インストールしています : lsyncd-2.1.5-0.el6.x86_64 1/1
Verifying : lsyncd-2.1.5-0.el6.x86_64 1/1

lsyncd.x86_64 0:2.1.5-0.el6




Lyscd – Live Syncing (Mirror) Daemon uses inotify to detect that a change has been made to the directory to be monitored, and uses rsync etc. to synchronize that changed files.

You can set it to call another tool instead of rsync.

Since synchronization is done on a file basis, it is not suitable for duplicating databases and the like.

– Regarding file updates monitored by kernel inotify, use API to monitor updates.
– Implement rsync to the mirror destination rsyncd (default is to use rsync) when file update occurs, realizing directory mirroring in real time.
– In addition to the default rsync, it is possible to use DRDB, GlusterFS, BindFS, etc. as a synchronization method.