![]() ![]() ![]() Since the I/O Kit provides this functionality, you must call it from C++ code." "Although OS X does not have traditional BSD-style shutdown hooks, the I/O Kit provides equivalent functionality in recent versions. It does not look like Apple provides libraries to catch those notifications in any other language.įrom the "Kernel Programming" manual from Apple, page 150: It looks like the most straightforward way would be to write a small C++ application that would run as a daemon with launchctl, catch the shutdown notification but ignore the reboot notification (see below) and then call whatever is given to it as arguments, e.g. sudo launchctl load -w /Library/LaunchDaemons/ist Then call launchctl command which load and unload daemons/agents. # INSERT HERE THE COMMAND YOU WANT EXECUTE AT STARTUP OR SERVICE LOAD # INSERT HERE THE COMMAND YOU WANT EXECUTE AT SHUTDOWN OR SERVICE UNLOAD This script boot-shutdown.sh will be loaded and executed at every boot/shutdown. System/Library/LaunchDaemons Mac OS X System wide daemons. System/Library/LaunchAgents Mac OS X Per-user agents. Library/LaunchDaemons System wide daemons provided by the administrator. Library/LaunchAgents Per-user agents provided by the administrator. ~/Library/LaunchAgents Per-user agents provided by the user. There are many directories where the plist file could be placed, it depends from what you need, the rights of the process and so on. You can place this file into /Library/LaunchDaemons. This is a sample of the plist file you could use: Few days ago I published on github a configuration/script able to be executed at boot/shutdown.īasically on Mac OS X you could/should use a System wide and per-user daemon/agent configuration file (plist) in conjunction with a bash script file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |