1

I'm trying to set up a service, on root, that will automatically start monetdb database after system startup because monetdb doesn't provide such mechanism. I've created /etc/init.d/monetdb script file:

#!/bin/sh
#
# /etc/init.d/monetdb
# Subsystem file for "MonetDB" starter
#
# chkconfig: 2345 95 05
#
# processname: MonetDB
# pidfile: /var/run/MonetDB.pid

. /etc/init.d/functions

case "$1" in
start)
        su - monetka -c ". start.sh"

        touch /var/lock/subsys/monetdb
        ;;
stop)
        su - monetka -c ". stop.sh"

        rm -f /var/lock/subsys/monetdb
        ;;
status)
        status monetdb
        ;;
restart|reload|condrestart)
        /etc/init.d/monetdb stop
        /etc/init.d/monetdb start
        ;;
*)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
esac
exit 2

I'm using self-made start.sh and stop.sh scripts located on monetka user which are executing fine each time. But when I want to start my service I'm getting an error and the following information:

monetdb.service - SYSV: MonetDB starter
   Loaded: loaded (/etc/rc.d/init.d/monetdb)
   Active: failed (Result: exit-code) since śro 2015-04-29 14:36:30 CEST; 16min ago
  Process: 5390 ExecStart=/etc/rc.d/init.d/monetdb start (code=exited, status=2)

kwi 29 14:36:30 yamny.centOS systemd[1]: Starting SYSV: MonetDB starter...
kwi 29 14:36:30 yamny.centOS su[5391]: (to monetka) root on none
kwi 29 14:36:30 yamny.centOS monetdb[5390]: [śro, 29 kwi 2015, 14:36:30 CEST] MonetDB: dbfarm jest już ur...miona
kwi 29 14:36:30 yamny.centOS monetdb[5390]: [śro, 29 kwi 2015, 14:36:30 CEST] MonetDB: baza demo jest już...miona
kwi 29 14:36:30 yamny.centOS systemd[1]: monetdb.service: control process exited, code=exited status=2
kwi 29 14:36:30 yamny.centOS systemd[1]: Failed to start SYSV: MonetDB starter.
kwi 29 14:36:30 yamny.centOS systemd[1]: Unit monetdb.service entered failed state.

Also, according to the report above, start.sh script is doing fine (as I stated before).

What I did so far:

  1. Created /etc/init.d/monetdb script on root
  2. Added service with chkconfig --add monetdb
  3. Start the service with systemctl start monetdb.service

2 Answers 2

0

Ok, I resolved the problem after deleting some lines from the /etc/init.d/monetdb script

#!/bin/sh
#
# /etc/init.d/monetdb
#
# chkconfig: 2345 95 05
# description: MonetDB starter
#
case "$1" in
start)
        su - monetka -c ". start.sh"
        ;;
stop)
        su - monetka -c ". stop.sh"
        ;;
restart)
        /etc/init.d/monetdb stop
        /etc/init.d/monetdb start
        ;;
esac

Then added service with chkconfig --add monetdb, and systemctl start/stop monetdb works like a charm...

1
  • Ok, but what was the problem with the first version of the script?
    – Bilthon
    Commented Oct 25, 2015 at 20:45
0

It's possible that "/etc/init.d/functions" didn't exist which would cause the original script to fail.

Given Ramhound's comment, I realize that I could have been clearer about my answer. I ran into exactly the same problem, and in my case the script failed because the file /etc/init.d/functions didn't exist. (On my CentOS 6.7 it's located at /etc/rc.d/init.d/functions). Given that Yammy had self-solved his problem by "deleting some lines" from his original script (which included the problematic /etc/init.d/functions reference), I thought others might be helped by a more specific answer.

That said, the script might also have additional problems which is why I phrased my answer as "It's possible that..."

I'm surprised that Ramhound finds that my response doesn't provide an answer and that it requires clarification from the asker. Perhaps Ramhound could provide a little more clarification about where he felt my answer required clarification from the original poster. Inquiring minds want to know.

0

You must log in to answer this question.

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