/bin/bash -c 'while true; do \
/usr/bin/etcdctl set my-container \
"{\"host\": \"1\", \"port\": $(/usr/bin/docker port my-container 5000 | cut -d":" -f2)}" \
--ttl 60; \
sleep 45; \
done'ExecStart , systemd , . , , systemd. systemd shlex Python Shellwords Ruby, , systemd-escape:$ man systemd-escape | head
SYSTEMD-ESCAPE(1) systemd-escape SYSTEMD-ESCAPE(1)
NAME
systemd-escape - Escape strings for usage in system unit names
SYNOPSIS
systemd-escape [OPTIONS...] [STRING...]
DESCRIPTION
systemd-escape may be used to escape strings for inclusion in systemd unit names.$ systemd-escape 'while true;do /usr/bin/etcdctl set my-container "{\"host\": \"1\", \"port\": $(/usr/bin/docker port my-container 5000 | cut -d":" -f2)}" --ttl 60;sleep 45;done'
while\x20true\x3bdo\x20-usr-bin-etcdctl\x20set\x20my\x2dcontainer\x20\x22\x7b\x5c\x22host\x5c\x22:\x20\x5c\x221\x5c\x22\x2c\x20\x5c\x22port\x5c\x22:\x20\x24\x28-usr-bin-docker\x20port\x20my\x2dcontainer\x205000\x20\x7c\x20cut\x20\x2dd\x22:\x22\x20\x2df2\x29\x7d\x22\x20\x2d\x2dttl\x2060\x3bsleep\x2045\x3bdone
tail, cat, less grep . . , vim less . , .journalctl, .journald .# for some reason these two options are necessary on jdk6 on Ubuntu
# accord to the docs they are not necessary, but otw jconsole cannot
# do a local attach
...[Unit]
Description=ZooKeeper
[Service]
Type=simple
Restart=always
RestartSec=5
EnvironmentFile=/etc/sysconfig/zookeeper
ExecStart=/usr/bin/java -cp ${ZK_CLASSPATH} ${JVM_FLAGS} org.apache.zookeeper.server.quorum.QuorumPeerMain ${ZOO_CFG_FILE}
[Install]
WantedBy=multi-user.targetZK_CLASSPATH=/opt/zookeeper:/opt/zookeeper/lib:/etc/zookeeper
JVM_FLAGS=-Xmx=2g
ZOO_CFG_FILE=/etc/zookeeper/zoo.cfgsyslog-ng rsyslog. , .[Service]
...
Restart=always
RestartSec=1stop , , , . , systemd , , .while true ; do
if pgrep serviceB ; then
start_service
break
else
sleep 1
fi
done[Unit]
Description=Service A
After=serviceB.service
Before=serviceC.serviceserviceA serviceB, serviceC. , drop-in , . , .[Unit]
Description=Service A
ConditionPathExists=/etc/sysconfig/serviceA/etc/sysconfig/serviceA. , .rsyslog cloud-final. , cloud-final cloud-init.rsyslog.service /usr/lib/systemd/system/rsyslog.service, . drop-in /etc/systemd/system/rsyslog.service.d/after-cloudinit.conf:[Unit]
After=cloud-final.service.conf. , . drop-in , rsyslog , cloud-final.service /.%02d-%s.conf.[Service]
ExecStartPre=ExecStartPre . ExecStartPre , , .$ sudo journalctl -u rsyslog.serviceless rsyslog.service. :$ sudo journalctl -u rsyslog.service -ftail -f .logrotate, .rsyslog syslog-ng , , syslog, syslog.systemctl journalctl, :Source: https://habr.com/ru/post/325792/
All Articles