I want to start Zookeeper daemon after Ubuntu server 16.04 booting (not after logging) under user named zookeeper. So I changed the file /etc/rc.local
like the following:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 'never'; defrag_file_pathname
su -c '$ZOOKEEPER_HOME/bin/zkServer.sh start' zookeeper &
exit 0
, adding the line su -c '$ZOOKEEPER_HOME/bin/zkServer.sh start' zookeeper &
before exit 0
. But the process is not started after restarting!
What's wrong here?
details: The zookeeper user is in sudo group and has password.
details: When I run command su -c '$ZOOKEEPER_HOME/bin/zkServer.sh start' zookeeper &
in terminal, it needs password to run.
systemd
system, so, maybe write a service description file instead? Here's an example btw: https://gist.github.com/gambtho/36a2f01e9e7d8c1b0046fb074f1a44ee (I don't think you need all the details though). – wvxvw Nov 23 '17 at 13:37'$ZOOKEEPER_HOME/bin/zkServer.sh start' zookeeper
line, is'$ZOOKEEPER_HOME/bin/zkServer.sh start'
different fromzookeeper
or is it an argument pass in? – George Udosen Dec 13 '17 at 07:32$ZOOKEEPER_HOME/bin/zkServer.sh
withstart
argument, and the user I want to run this command with iszookeeper
. I tried without using variable $ZOOKEEPER_HOME but no difference. Thanks! – Soheil Pourbafrani Dec 13 '17 at 07:39zookeeper
. The post you suggest, running as a user try to run a command without password as another user. – Soheil Pourbafrani Dec 13 '17 at 12:02