How to run script on startup and shutdown OS X El Capitan

Solution 1:

I believe the correction to the shell script should be:

function fstartup()
{
    //put folder into ramdisk
     tail -f /dev/null &
     wait $!
}
function fshutdown()
{
    //detach ramdisk

}

function framdisk()
{
    //do something
}
trap fshutdown SIGTERM
trap fshutdown SIGKILL
fstartup;

So that it will wait during the startup, not the shutdown.

I'm currently running my version and it appears to work fine, it correctly runs the shutdown function when the computer is shutting down.