To see if your script is running, try outputting things to a file during its execution, and open that file to see if it's indeed running.
Now, "B" is the issue, and we can fix it in 2 ways:
- Install cron on iPod
- Use launchd
I don't know if there's yet a cron port to the iOS
, so "1" might be a problem.
However, we can do "2", since launchd comes on iOS.
To use launchd, you need to create an XML plist file in
[/Library/LaunchDaemons], do a couple of steps and that's it
...
Create the file
[/Library/LaunchDaemons/com.scripts.myscript.plist] and have its content as follows (in
bold what you need to change):
Code:
<?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>scripts.myscript</string>
<key>OnDemand</key>
<true/>
<key>Program</key>
<string>/the/full/path/to/your/script.sh</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>16</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
The key tags for the cron are follows:
- Minute
- Hour
- Day
- Weekday
- Month
They should be followed by an
<integer> tag, to specify their value.
If you don't specify a tag, it will be as if you used '*' in cron.
The plist file name can be whatever you want, mind you, so use what you think is logical.
Now, you need to let launchd know about your plist entry, so execute:
Code:
iPod:~ mobile$ launchctl load /Library/LaunchDaemons/com.scripts.myscript.plist
And it's done (hopefully)!
You can always check the
launchctl man page.