[systemd-devel] timers always run when time changes

Likang Wang laborish at gmail.com
Thu Apr 30 20:31:26 PDT 2015


The custom time syncing service file does not have
"Before=time-sync.target".

In fact, not only when the time changes by the custom time syncing service
,but also when I set the time manually by "date -s 2015-05-01 11:08:00",
the timer and the same-name service will run.


Here is the custom time syncing service file:
#cat /lib/systemd/system/XXXXXX.service
[Unit]
Description=XXXXXXX Daemon
After=ppp.service

[Service]
Type=simple
ExecStart=/usr/lib/XXXXXX/xxxxxx/bin/xxxxxx
Restart=always


Here is the log when I set the time manually by "date -s 2015-05-01
11:08:00"
#systemctl status updateimage.timer -l
— updateimage.timer - Update image
   Loaded: loaded (/lib/systemd/system/updateimage.timer; disabled)
   Active: active (waiting) since Fri 2010-01-01 08:00:04 CST; 5 years 3
months ago

May 01 11:08:00 systemd[1]: Timer elapsed on updateimage.timer
May 01 11:08:00 systemd[1]: updateimage.timer changed waiting -> running
May 01 11:08:00 systemd[1]: updateimage.timer got notified about unit
deactivation.
May 01 11:08:00 systemd[1]: updateimage.timer: Realtime timer elapses at
Sat 2015-05-02 02:00:00 CST.

#systemctl status updateimage.service -l
â— updateimage.service - Update image
   Loaded: loaded (/lib/systemd/system/updateimage.service; static)
   Active: inactive (dead) since Fri 2015-05-01 11:08:00 CST; 18min ago
  Process: 579 ExecStart=/bin/updateImage.sh (code=exited, status=0/SUCCESS)
 Main PID: 579 (code=exited, status=0/SUCCESS)

May 01 11:08:00 systemd[1]: Enqueued job updateimage.service/start as 1019
May 01 11:08:00 systemd[1]: Forked /bin/updateImage.sh as 579
May 01 11:08:00 systemd[1]: updateimage.service changed dead -> start
May 01 11:08:00 systemd[579]: Executing: /bin/updateImage.sh
May 01 11:08:00 systemd[1]: Child 579 belongs to updateimage.service


--
laborish




2015-05-01 10:34 GMT+08:00 Cameron Norman <camerontnorman at gmail.com>:

> On Thu, Apr 30, 2015 at 6:35 PM, Likang Wang <laborish at gmail.com> wrote:
> > Hi all,
> >
> > The entire system is running on an embedded box, and the system time
> will be
> > set to 2008-01-01 00:00:00 after every reboot. My app running on the box
> > will get the real time from my server and update time on the box after
> every
> > booting.(I could not use NTP or systemd-timesyncd for some other reason)
>
> Does the service file for this custom time syncing service have the
> directive `Before=time-sync.target` ? If it does, are you sure that
> when it is considered running by systemd that the time has indeed been
> synced?
>
> Cheers,
> --
> Cameron Norman
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150501/4ab016f5/attachment.html>


More information about the systemd-devel mailing list