[英]How to execute a script (e.g. mvnw) as if you were in that directory in the background?
I have my application with maven where you can 'cd' to this directory /path/app/execute/. 我的应用程序带有maven,您可以在其中“ cd”到该目录/ path / app / execute /。 and run 'mvnw' and the app starts fine.
并运行“ mvnw”,应用启动正常。
My problem is I want to create a start script in the parent directory here: /path/app/startMyApp.sh. 我的问题是我想在此处的父目录中创建一个启动脚本:/path/app/startMyApp.sh。
It's contents are: 它的内容是:
nohup /path/app/execute/mvnw &
My problem is, when I cd to /path/app and run './startMyApp.sh', I am getting: 我的问题是,当我CD到/ path / app并运行'./startMyApp.sh'时,我得到了:
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
错误:找不到或加载主类org.apache.maven.wrapper.MavenWrapperMain
How can I keep my script in the parent directory of the "mvnw" executable, and be able to execute it as if I were in that directory as a background process (nohup) in the script? 如何将脚本保存在“ mvnw”可执行文件的父目录中,并能够像在脚本中作为后台进程(nohup)一样在该目录中执行它?
注意问题中“ mvnw”和“ mvn”之间的区别,如果问题的症结在于将目录更改为nohup
下的/ path / app / execute,则:
nohup sh -c 'cd /path/app/execute; mvnw' &
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.