Convert init script to systemd - executable path is not absolute

9,665

systemd needs an absolute path:

ExecStart=/usr/bin/nohup /usr/local/bin/php -f /home/user/www/myservice.php > /dev/null 2>&1
Share:
9,665

Related videos on Youtube

Reado
Author by

Reado

Updated on September 18, 2022

Comments

  • Reado
    Reado over 1 year

    I am trying to convert one of my init scripts to systemd but to no avail.

    [Unit]
    Description=My Service
    After=network.target
    Wants=mysql.service
    
    [Service]
    Type=oneshot
    PIDFile=/var/run/MyService.pid
    ExecStart=nohup /usr/local/bin/php -f /home/user/www/myservice.php > /dev/null 2>&1
    
    [Install]
    WantedBy=multi-user.target
    

    The output:

    root@localserver [/etc/systemd/system]# service myservice restart
    Redirecting to /bin/systemctl restart  myservice.service
    Failed to restart myservice.service: Unit myservice.service failed to load: Invalid argument. See system logs and 'systemctl status myservice.service' for details.
    root@localserver [/etc/systemd/system]# service myservice status
    Redirecting to /bin/systemctl status  myservice.service
    â myservice.service - My Service
       Loaded: error (Reason: Invalid argument)
       Active: activating (start) since Tue 2016-04-12 12:48:18 BST; 1min 9s ago
     Main PID: 22892 (php)
       CGroup: /system.slice/myservice.service
               ââ22892 /usr/local/bin/php -f /home/user/www/myservice.php
    
    Apr 12 12:48:18 localserver systemd[1]: Starting My Service...
    Apr 12 12:48:27 localserver systemd[1]: [/etc/systemd/system/myservice.service:9] Executable path is not absolute, ignoring: nohup /usr/local/bin/php -f /home/user/www/myservice.php > /dev/null 2>&1
    Apr 12 12:48:27 localserver systemd[1]: myservice.service lacks both ExecStart= and ExecStop= setting. Refusing.
    root@localserver [/etc/systemd/system]#
    

    Any idea why it is not working?

    • Eric Renouf
      Eric Renouf about 8 years
      Are you sure you need to nohup your service when run under sytemd?
  • JdeBP
    JdeBP almost 8 years
    It actually had one, ironically. The presence of nohup is wrong. So is the attempt at redirection using shell syntax.