I have a Raspberry Pi running Debian Jessie.

The Pi is acting as a VPN gateway for when I travel.

I have a monitor script - python - which, when triggered, generates a list of connected clients and sends that list via MQTT to my network monitor machine. This all works perfectly. Every time I launch the script, it runs and I can see the client list 'at the other end' of the MQTT chain. The client list includes a timestamp from the VPN machine which shows at what time it was triggered to give the report.

I have additionally configured a Systemd service file so I can automatically trigger this script. This is my service file - 'vpnmon.service':

Description=VPN Monitor script

ExecStart=/usr/bin/python /home/nick/lib/checkusers.py

This is triggered by a systemd timer 'vpnmon.timer':

Description=Runs vpnmon script every five seconds



This does all 'work'.

BUT the script is seemingly not triggered at regular time intervals. Sometimes 10 seconds, sometimes 15 sometimes 20 - sometimes a whole minute elapses before it is triggered.

So I type the following to query the service status:

systemctl status vpnmon.service

I get a good result:

● vpnmon.service - VPN Monitor script
   Loaded: loaded (/lib/systemd/system/vpnmon.service; static)
   Active: inactive (dead) since Thu 2017-09-28 09:52:01 UTC; 1s ago
  Process: 1138 ExecStart=/usr/bin/python /home/nick/lib/checkusers.py (code=exi                                   ted, status=0/SUCCESS)
 Main PID: 1138 (code=exited, status=0/SUCCESS)

In the course of doing this I noticed a weird thing. If I repeatedly query the status, I constantly get good results, and I notice that the very act of querying the service status via command line like this causes the script to be triggered exactly when expected i.e. at 5 second intervals...

What is there in the act of querying a systemd service status could cause the apparent intermittant triggering to disappear??

Is this something akin to Python 'buffering; when you use a script to write stuff to a file??

  • Could I bother you for a more descriptive title than "weird issue"? Perhaps use some words that describe the configuration or errors.
    – Jeff Schaller
    Sep 28, 2017 at 10:09
  • 1
    I would look at the AccuracySec setting as specified in the systemd.timer man page. Apparently the default accuracy is set to 1 minute. This could possibly account for the restart timing inconsistencies. Sep 28, 2017 at 10:21

1 Answer 1


Raman - thank you! Nailed it.

I added the following to vpnmon.timer:


It works perfectly now.

Details of that setting are here:


Thank you.

You must log in to answer this question.

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