Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

getting permission denied error on stopping a service

Hi,
On executing the command : service snippet stop i am getting the following error :
env: /etc/init.d/snippet: Permission Denied

what could be the reason ?

Here is my snippet file :
#!/bin/bash
# chkconfig: 3 99 99
# description: code snippet app
# processname: snippet

. /etc/rc.d/init.d/functions
prog="flocksnippet"
user="flocksnippet"

start()
{
PATH="$PATH:/bin"
PORT=$(awk -F= '/^PORT=/{print $2}' /root/flockApps.properties)
FLOCK_APPS_CONFIG=$(awk -F= '/^FLOCK_APPS_CONFIG=/{print $2}' /root/flockApps.properties)
cd /opt/flock-snippets/
exec="mvn jetty:run -DFLOCK_APPS_CONFIG=${FLOCK_APPS_CONFIG} -DPORT=${PORT}"
daemon --user=$user $exec &
}

stop()
{
PATH="$PATH:/bin"
echo -n $"Stopping $prog: "
killproc $prog

}

restart()
{
stop
start
}

case "$1" in
    start)
        $1
        ;;
    stop)
        $1
        ;;
    restart)
        $1
        ;;
    *)
       exit 2
esac
exit $?

Open in new window

The user=flocksnippet is  a /sbin/nologin user and the filie snippet is owned by root.
ASKER CERTIFIED SOLUTION
Avatar of Prashant Shrivastava
Prashant Shrivastava
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial