rc.common not run on mac os x

微笑、不失礼 提交于 2019-12-25 05:10:04

问题


I want to run a shell script on startup

by google ,I found that I could add shell in rc.common

so I added the code below at the end of rc.common

is it a permission problem?

## rc.common test ##
touch ~/test.txt

reboot,there is no test.txt in my user fold

when I test it in terminal manualy ,it's ok

ls -l /etc/rc.common
-rw-r--r--  1 guirong  wheel  1737  3 30 22:36 /etc/rc.common

where is the problem? my system verison is 10.7.3 is it not ran by default in os x?


回答1:


If you want the script to be run only for the current user, you should use ~/.bashrc instead

Later edit: I misread your question. If you want something to run at startup, you should look into launchd here




回答2:


Just as an added bit of information about what was happening; /etc/rc.common runs as root, so when you were touching the file at ~/test.txt it would have been ending up in /var/root (the root user's home directory)



来源:https://stackoverflow.com/questions/9945745/rc-common-not-run-on-mac-os-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!