Running forever within su as a different user

lwood

I am experiencing weird behavior with forever, which I want to use to keep alive my node app.

I want to run my forever processes as my regular user lwood, not as root.

I need to know how to run forever properly within root mode, but as the user lwood. (This is needed because, for example as a special case, upstart scripts run as root.)

These commands illustrate my problem (I'm on Ubuntu 12.04, and $ is regular user and # is root):

$ su
[type in su password]

# cd /home/lwood/myapp
# sudo -u lwood forever -a -l "/home/lwood/myapp/logfile.log" start app.js
info:    Forever processing file: app.js

# forever list    
info:    No forever processes running

# exit

$ forever list
info:    No forever processes running

So forever successfully started, yet no processes are running under neither lwood nor root!

How can I fix this problem?

Tony Chen

If you're using upstart, try this (putting it to your upstart script)

exec su -s /bin/sh -c 'exec "$0" "$@"' username -- /usr/local/bin/forever ...

reference: https://superuser.com/questions/213416/running-upstart-jobs-as-unprivileged-users

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Running iOS app in the background forever

From Dev

Running a timer in python forever

From Dev

Sparql query running forever

From Dev

Unit test is running forever with Tasks

From Dev

Why does this script running su never seem to terminate if I change user inside the script?

From Dev

su options - running command as another user

From Dev

su as different user in Linux reports 'missing }'

From Dev

Why are PATH variables different when running via sudo and su?

From Dev

Running forever within su as a different user

From Dev

su to different user no longer working in 12.04 LTS

From Dev

Why is this Perl script running forever?

From Dev

Running su on Android root

From Dev

Escape within su and awk

From Dev

Trouble running forever on ubuntu

From Dev

Running su noninteractively?

From Dev

Running Apache as a different user

From Dev

Command behavior is different when executed by an other user (via su -c)

From Dev

Running Apache as a different user 5

From Dev

How to run command as a different user when there are no sudo or su commands

From Dev

running a jquery task forever

From Dev

When the user of a shell is `root`, does running `su` on another user name ask for password of the other user?

From Dev

Why is there a different result when running as user1 and su - user1 -c "command"?

From Dev

su - user Vs sudo su - user

From Dev

Unit test is running forever with Tasks

From Dev

Running command via su as www-data user fails silently

From Dev

Running an application as different user

From Dev

Running script from different user

From Dev

Running as a host user within a Docker container

From Dev

Sonarqube background tasks running forever

Related Related

HotTag

Archive