02-24-2018, 07:12 AM #1
- Member Since
- Feb 07, 2010
Trouble Getting launchd Scripts Running Properly
- Rep Power
I'm trying to get a system startup script running with launchd (in 10.11.6). This script creates a RAM disk, then copies some files to it. The launchd plist is very simple, and seems to be working as I'm getting my 'touched' file every time. But that's all I get through launchd. I don't get a ram disk! This .plist file is in /Library/LaunchDaemons
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.myscript.make-ramdisk</string> <key>Program</key> <string>/ramdisk-scripts/make-ramdisk</string> <key>RunAtLoad</key> <true/> </dict> </plist>
Here is my script...
#!/bin/bash touch /Users/myusername/Desktop/ram-disk-logs/startup-make-ramdisk-$(date +"%Y_%m_%d_%I_%M_%p").log sleep 2 ## make a ram disk that is approximaly 4GB in size /usr/sbin/diskutil erasevolume HFS+ "webfolder" `/usr/bin/hdiutil attach ram://8000000 -notremovable -nomount` ## copy contents of the ramdisk backup to the ramdisk cp -R /webfolder-backup/* /Volumes/webfolder/ ## make me the owner chown -R myusername /Volumes/webfolder/ chmod -R 777 /Volumes/webfolder/
But the really fun part is that when launchd runs this script, it only gets to the `touch` line, and doesn't actually make the RAM disk. I have no idea what could be causing this. This makes it very hard to try to troubleshoot since it WORKS when I try to troubleshoot, it only doesn't work in practice.
I also need to figure out how to make a shutdown script, to save the contents of this RAM disk on shutdown. A feature which seems to be oddly missing from launchd. But first things first, I can't even get the RAM disk created, never mind gracefully removed.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By Lateralus138 in forum Switcher HangoutReplies: 0Last Post: 03-15-2015, 02:19 PM
By kaoticsolja in forum macOS - Apps and GamesReplies: 5Last Post: 05-27-2011, 01:29 PM
By kc0mmy in forum macOS - Operating SystemReplies: 6Last Post: 10-06-2010, 07:31 AM
By Emoguy55 in forum macOS - Operating SystemReplies: 1Last Post: 12-13-2007, 10:36 AM
By pirrip in forum Switcher HangoutReplies: 1Last Post: 06-29-2005, 03:42 PM