0

I am running supervisorctl command with root and without root user. With root user it is ok but with sudo it is not working. Here is the output:

[ec2-user@stg etc]$ sudo supervisorctl status
sudo: supervisorctl: command not found

Now I run with root user:

[ec2-user@stg etc]$ sudo su -
Last login: Tue Jun  6 03:02:55 UTC 2017 on pts/1
[root@stg ~]# supervisorctl status
kafka                            BACKOFF   Exited too quickly (process log may have details)
zookeeper                        RUNNING   pid 24697, uptime 0:25:11

PATH variable is shown below:

[root@stg ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/root/bin

[ec2-user@stg etc]$ echo $PATH
/home/ec2-user/.pyenv/shims:/home/ec2-user/.pyenv/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin

Please help me to fix it.

0

This is a common problem, and you've correctly identified the source. There are two possible solutions, making sure that all PATH entries present for root are also present for ec2-user by adding the following to your bash profile

export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/root/bin:$PATH"

Or, IMO the more elegant solution, make sure your PATH includes the specific directory containing supervisorctl.

You should start by finding the parent directory by running whereis supervisorctl under root.

# whereis supervisorctl
/whatever/path/bin

Which should then be included in your bash profile

$PATH="/whatever/path/bin:$PATH"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.