I have generally speaking followed the instructions here , and tried using su - <myuser> -c "the command"
within the service script there. However, I'm trying to run a Clojure application via Leiningen, and it seems that neither lein
can't be found by the process. I can use something like su - <myuser> -c "/path/to/lein run ..."
, but then I get an error that java
isn't found.
How do I get this command to run such that it has access to my environment?
This turned out to be quite simple. I did
su - <myuser> -c "source ~/.bashrc; cd ~/chicken-coop; ~/bin/lein run"`
The key is to source ~/.bashrc;
, which adds the normal things to your path, so lein knows where java
is.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.