1

Hi I heard that you can write cron job into plist and put it to JB iPhone /Library/LaunchDaemons folder in plist format

I would like to backup the photo folder every 300 seconds, so I put a com.backup.plist like this into /Library/LaunchDaemons folder

<?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>KeepAlive</key>
    <true/>

    <key>Label</key>
    <string>com.backup</string>

    <key>Program</key>
    <string>/bin/cp</string>

    <key>ProgramArguments</key>
    <array>
        <string>-u</string>
        <string>/private/var/mobile/Media/DCIM/100APPLE/*.*</string>
        <string>/private/var/backup</string>
    </array>

    <key>StartInterval</key>
    <integer>300</integer>

</dict>
</plist>

I have created a folder of /private/var/backup with access right of 777 mobile:mobile

I rebooted the iPhone, however, the script just doesn't work

Does the failure refer to the "cp" command access right? or should I change the /private/var/backup folder access right to something else?

btw I'm running iOS 4.3.3 Jailbreak iPhone 4

Many thanks for reading

migrated from superuser.com Jun 10 '11 at 5:49

This question came from our site for computer enthusiasts and power users.

  • 1
    Do you get any error messages in the log files? – Kerri Shotts Jun 14 '11 at 3:35
  • where will the log file of launchdaemons be located? – Unreality Jun 16 '11 at 6:26
0
+50

From the man lanuchctl

Note that per-user configuration files (LaunchAgents) must be owned by the user loading them. All system-wide daemons (LaunchDaemons) must be owned by root. Configuration files must not be group- or world-writable. These restrictions are in place for security reasons, as allowing writability to a launchd configuration file allows one to specify which executable will be launched.

So,

chown root  /Library/LaunchDaemons/your.plist 
chgrp wheel /Library/LaunchDaemons/your.plist 
chmod 644   /Library/LaunchDaemons/your.plist

and after these:

launchctl load /Library/LaunchDaemons/your.plist
0

According to Wikipedia's article on cp:

To copy a directory to a directory (-r or -R must be used)

So try adding <string>-r</string> to the list of arguments. Reboot your device and after 5 minutes (300 seconds) check if it worked.

Ad@m

  • since running code cp -u /private/var/mobile/Media/DCIM/100APPLE/*.* /private/var/backup code directly in shell has no problem copying the files, so I believe the problem isn't about the argument of cp – Unreality Jun 20 '11 at 8:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .