Mac修改开机启动项

第二部分: 手动测试服务,以命令的方式快速启动服务,主要是写plist前的验证.
launchctl:


1. 快速验证启动服务程序是否能成功运行,不需要复制org.apache.tomcat.plist到 

~/Library/LaunchAgents

/Library/LaunchAgents

/Library/LaunchDaemons

/System/Library/LaunchAgents

/System/Library/LaunchDaemons

意思是快速验证一个需要部署的程序是否能正确运行,当然配置也得和plist一样.

[plain] view plain copy

  1. launchctl submit -l org.apache.tomcat -o `pwd`/stdout.log -e `pwd`/stderr.log -p /Users/apple/Desktop/apache-tomcat-5.5.25/bin/catalina.sh run  


2. 停止服务

[plain] view plain copy

  1. launchctl stop org.apache.tomcat  


3. 移除当前job里的服务

[plain] view plain copy

  1. launchctl remove org.apache.tomcat  


4. 提示错误 launchctl run error: File exists

表示job已经启动过,需要先停止再移除才可以重新运行.

[plain] view plain copy

  1. launchctl stop org.apache.tomcat  
  2. launchctl remove org.apache.tomcat  


5. 配置的输出提示错误,说明没有配置 JAVA_HOME 环境变量.

[plain] view plain copy

  1. Neither the JAVA_HOME nor the JRE_HOME environment variable is defined  
  2. At least one of these environment variable is needed to run this program  


6. 设置环境变量

[plain] view plain copy

  1. launchctl setenv JAVA_HOME `/usr/libexec/java_home`  


7. 删除环境变量

[plain] view plain copy

  1. launchctl unsetenv JAVA_HOME  

http://blog.csdn.net/infoworld/article/details/47419877

猜你喜欢

转载自my.oschina.net/u/261246/blog/909016