I have a script that runs a mysqldump and then a mysql insert from bash. It works fine from terminal, even as root (which I believe LaunchD runs as) but it will not run the mysql insert from launchd, but will run the mysqldump.
Script is:
#!/bin/bash
mysqldump -u root -pmypass my_db | gzip -9 > /path/to/dump.sql.gz
mysql -u root -pmypass my_db2 < /path/to/insert.sql
and my com.me.BackupThing.plist (from /Library/LaunchAgents), which does run and executes all but the mysql command:
<?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>com.me.BackupThing</string>
<key>ProgramArguments</key>
<array>
<string>/full/path/to/above/script.sh</string>
</array>
<key>QueueDirectories</key>
<array/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>01</integer>
<key>Minute</key>
<integer>00</integer>
</dict>
<key>WatchPaths</key>
<array/>
<key>UserName</key>
<string>administrator</string>
</dict>
</plist>
All runs from terminal as root, and mysql's bin is exported on roots command path.
Why would it ignore the mysql command from launchd?
EDIT
Thanks to arco444 for solution, full path was required on mysql for some reason, new script is:
#!/bin/bash
mysqldump -u root -pmypass my_db | gzip -9 > /path/to/dump.sql.gz
/path/to/mysql/bin/mysql -u root -pmypass my_db2 < /path/to/insert.sql