Init.d script not working on startup: Failed to start SYSV

11,046
Process: 2785 ExecStart=/etc/init.d/keystone start (code=exited, status=203/EXEC)
…
Oct 13 07:39:12 test-vm systemd[2785]: Failed at step EXEC spawning /etc/init.d/keystone: Exec format error

… which is entirely correct. Your file is not an executable script. It lacks an interpreter. It's also not in the correct form that is prescribed for old van Smoorenburg rc scripts by Debian Policy, hence the "SYSV:" (rather than "LSB:") that systemd has prefixed to its description.

But it's also a waste of time to fix it. Throw it away. Write a systemd service unit.

[Unit]
Description=Keystone CMS
Documentation=http://unix.stackexchange.com/a/316168/5132

[Service]
WorkingDirectory=/home/user/keystone
ExecStart=/opt/bitnami/nodejs/bin/node /home/user/keystone/keystone.js

[Install]
WantedBy=multi-user.target

Further reading

Share:
11,046

Related videos on Youtube

Peter Gerhat
Author by

Peter Gerhat

My profile is that of a software product owner with a strong engineering background. I like building end-to-end solutions that typically require a mix of technical skills, business skills, and mathematical knowledge. I understand how to optimize data algorithms, and how to explain my findings. My technical background allows me to deal with data at scale. I'm an active learner with a strong aptitude towards technology and discovering the new. My areas of expertise are Mobile and Data Analytics. I have a niche for data-driven apps. That area poses a set of new challenges and opportunities and also it is one of the most rapidly growing fields.

Updated on September 18, 2022

Comments

  • Peter Gerhat
    Peter Gerhat over 1 year

    The Keystone CMS system fails to run on startup. The problem is likely in this init.d startup script. I set the permissions, but something is still not right.

    $ sudo systemctl daemon-reload
    $ sudo service keystone start
    Job for keystone.service failed. See 'systemctl status keystone.service' and 'journalctl -xn' for details.
    $ sudo service keystone status
    ● keystone.service - SYSV: Keystone server daemon
       Loaded: loaded (/etc/init.d/keystone)
       Active: failed (Result: exit-code) since Thu 2016-10-13 07:39:12 UTC; 16s ago
      Process: 2785 ExecStart=/etc/init.d/keystone start (code=exited, status=203/EXEC)
     Main PID: 2698 (code=exited, status=216/GROUP)
    
    Oct 13 07:39:12 test-vm systemd[2785]: Failed at step EXEC spawning /etc/init.d/keystone: Exec format error
    Oct 13 07:39:12 test-vm systemd[1]: keystone.service: control process exited, code=exited status=203
    Oct 13 07:39:12 test-vm systemd[1]: Failed to start SYSV: Keystone server daemon.
    Oct 13 07:39:12 test-vm systemd[1]: Unit keystone.service entered failed state.
    

    It could be the script itself, which was created from a template. I was also thinking about linking it to one of /etc/rc?.d directories.

    I'm using Debian 8.6

    /etc/init.d/keystone:

    Subsystem file for "Keystone" server
    #
    # chkconfig: 2345 95 05
    # description: Keystone server daemon
    
    RETVAL=0
    prog="keystone"
    
    start() {       
            echo -n $"Starting $prog:"
    
            cd /home/user/keystone
            /opt/bitnami/nodejs/bin/node  /home/user/keystone/keystone.js
    
            RETVAL=$?
            [ "$RETVAL" = 0 ] && touch /var/lock/subsys/$prog
            echo
    }
    
    stop() {        
            echo -n $"Stopping $prog:"
    
            killproc $prog -TERM
            RETVAL=$?
            [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/$prog
            echo
    }
    
    reload() {
            echo -n $"Reloading $prog:"
            killproc $prog -HUP
            RETVAL=$?
            echo
    }
    
    case "$1" in
            start)
                    start
                    ;;
            stop)
                    stop
                    ;;
            restart)
                    stop
                    start
                    ;;
            reload)
                    reload
                    ;;
            condrestart)
                    if [ -f /var/lock/subsys/$prog ] ; then
                            stop
                            # avoid race
                            sleep 3
                            start
                    fi
                    ;;
            status)
                    status $prog
                    RETVAL=$?
                    ;;
            *)
                    echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
                    RETVAL=1
    esac
    exit $RETVAL