我有以下的新贵工作:
# hwclock - adjust system clock and timezone
#
# The hwclock task adjusts the system clock when the hardware clock is
# set to localtime (e.g. when dual-booting with Windows), and also
# ensures that the system timezone is set so that timestamps are written
# to FAT devices.
description "adjust system clock and timezone"
start on starting mountall
task
script
exec hwclock --systz --utc --noadjfile
end script我想把这个换成systemd服务。
如何在systemd上实现start on starting mountall?
我创建了systemd服务,如下所示,但我不知道如何执行start on starting mountall。
[Unit]
Description=hwclock
After=
Before=
[Service]
ExecStart=/sbin/hwclock --systz --utc --noadjfile发布于 2018-01-22 06:31:17
您将需要以下几行:
Requires=
After=如下文所述:
Requires=:此指令列出了该单元本质上依赖的任何单元。如果当前单元被激活,这里列出的单元也必须成功激活,否则此单元将失败。默认情况下,这些单元与当前单元并行启动。After=:本指令中列出的单元将在启动当前单元之前启动。这并不意味着依赖关系,如果需要,必须通过上述指令建立依赖关系。
其结构应是:
[Unit]
Description=hwclock
Requires= # mountall most happen
After= # mountall should have started before hwclock run
[Service]
Type=oneshort
ExecStart=/sbin/hwclock --systz --utc --noadjfile来自这里:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Upstart stanza | systemd unit file directive | systemd unit file section
| |
-------------------------------------------------------------------------
start on | Wants, Requires, Before, |
| After | Unit
--------------------------------------------------------------------------注意:这是一个Ubuntu系统,但应该是类似的。见:https://www.freedesktop.org/software/systemd/man/systemd.unit.html。
https://unix.stackexchange.com/questions/418749
复制相似问题