I am learning how to create a Launch Daemon. This job aims to create a text file on on the user's desktop on boot up. The plist file is placed in Library/LaunchDaemons/. Here is the plist file:
<?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.test.createFile</string>
<key>Program</key>
<string>/Users/hlocng/Desktop/createFile.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
... and here is the bash script:
#!/bin/bash
touch /Users/hlocng/Desktop/newFile.txt
I tried launchctl load /Library/LaunchDaemon/com.test.createFile
and there was no error but no file is created, not even when I reboot the computer.
I do not know what I am doing wrong. Any help is appreciated. Thanks you!