title: Does systemd support time-limited daemon?
body: <p>I have a daemon which runs for a pre-configured period of time and then quit. User can restart it if needed after that. It seems that systemd cannot handle this type of service. Below is the service file I tried. </p>
  
  <pre><code>[Unit]
  # DaemonXXX quits
  Description=DaemonXXX
  After=network.target
  
  [Service]
  Type=forking
  PIDFile=/var/run/daemonXXX.pid
  ExecStart=/usr/local/sbin/daemonXXX
  StandardOutput=journal
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>I can start service with above unit file. After the daemon quits, I'm also able to start it again by command <code>systemctrl start DaemonXXX</code>. But when the service quit after timeout, <code>systemd</code> complains that system is degraded because daemonXXX quits. If I add <code>RemainAfterExit</code> opton to <code>[Service]</code> section, </p>
  
  <pre><code>[Unit]
  # as above
  ...
  
  [Service]
  # as above
  ...
  RemainAfterExit=yes
  
  ...
  </code></pre>
  
  <p><code>systemd</code> will not complain of <code>degrarded</code> system but I am no longer able to restart the service again by command <code>systemctrl start daemonXXX</code> as <code>systemd</code> assumes that <code>daemonXXX</code> is running correctly and there is no need to restart it. Is there a way to solve it?</p>