简体   繁体   中英

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/. and run 'mvnw' and the app starts fine.

My problem is I want to create a start script in the parent directory here: /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:

Error: Could not find or load main class 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”和“ mvn”之间的区别,如果问题的症结在于将目录更改为nohup下的/ path / app / execute,则:

nohup sh -c 'cd /path/app/execute; mvnw' &

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM