I have the following upstart job:

# 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


    exec hwclock --systz --utc --noadjfile
end script

I would like to switch this to systemd service.

How should start on starting mountall be implemented on systemd?

I created the systemd service as below, but I do not know how to do start on starting mountall.


ExecStart=/sbin/hwclock --systz --utc --noadjfile
  • I think that's where the Before= line comes in! Jan 22, 2018 at 5:53
  • It's also probably Type=oneshot, because hwclock will exit when it's done. Jan 22, 2018 at 6:05
  • Check out systemd for upstart users and perhaps After=local-fs.target.
    – meuh
    Jan 22, 2018 at 9:37

1 Answer 1


You will need these lines:


As stated here:

Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.

After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.

The structure should be:

Requires= # mountall most happen
After= # mountall should have started before hwclock run

ExecStart=/sbin/hwclock --systz --utc --noadjfile

From here:

Upstart stanza | systemd unit file directive | systemd unit file section
               |                             |
start on       |    Wants, Requires, Before, |
               |    After                    |  Unit 

Note: This is for an Ubuntu system but should be similar. See: https://www.freedesktop.org/software/systemd/man/systemd.unit.html also.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .