Actually I want to make a RAM drive related to this script on my Mac.
Here is what I did:
- Disabled SIP in recovery mode using command "csrutil"
Created a plist file in /Library/LaunchDaemons/
and enteredlaunchctl -w /Library/LaunchDaemons/vn.magik.ramdisk.plist
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>vn.magik.ramdisk</string> <key>ProgramArguments</key> <array> <string>/Users/khacpm/ramdisk.sh</string> </array> <key>RunAtLoad</key> <true/> <key>StandardOutPath</key> <string>/Users/khacpm/ramdisk.log</string> <key>StandardErrorPath</key> <string>/Users/khacpm/ramdisk.err</string> </dict> </plist>
Created .sh file and put it in ~/ramdisk.sh
code:
function fstartup() { //put folder into ramdisk } function fshutdown() { //detach ramdisk } function framdisk() { //do something } trap fshutdown SIGTERM trap fshutdown SIGKILL fstartup;
The problem is, the function fstartup runs well but it seems like function fshutdown isn't called by the system.
cp
command can finish running. Is there any way to hold up the shutdown for a few seconds?