0

I am dynamically appending cron tasks to the user crontab

The tasks seem to be getting adde, crontab -e looks like:

*/10 * * * * /bin/sh /Users/john/Kiosk/app/content/update.sh
@reboot /usr/bin/open /Users/john/Kiosk/startup.command

Trouble is that it appears to be having no effect.

The content of startup.command:

cd /Users/john/Kiosk/app && /usr/bin/python -m SimpleHTTPServer &
sleep 5 && open http://localhost:8000

What am I getting wrong?

3 Answers 3

2

Do not use relative paths, buth full ones. Also with binaries.

Then, your line should be

*/10 * * * * /usr/bin/sh /home/<username>/Kiosk/app/content/update.sh
@reboot open /home/<username>/Kiosk/startup.command
10
  • Sure! It was a typo. Can also be /bin/sh, you can know it typing which sh.
    – fedorqui
    Jun 14, 2013 at 11:23
  • Hmm, that's all changed, but the reboot is certainly still having no effect!
    – Mild Fuzz
    Jun 14, 2013 at 11:43
  • Have you tried changing open to /bin/open (or... which open result)?
    – fedorqui
    Jun 14, 2013 at 11:44
  • @reboot /usr/bin/open /Users/john/Kiosk/startup.command is the command, which works when put straight into the terminal, but not on reboot
    – Mild Fuzz
    Jun 14, 2013 at 11:50
  • I have added more content into the question, hopefully this will assist you.
    – Mild Fuzz
    Jun 14, 2013 at 12:11
1

Taking the open command away did the trick

@reboot yourscript.command
0

The default path is /usr/bin:/bin, and tildes do work in the user crontab, so this should work:

*/10 * * * * bash ~/Kiosk/app/content/update.sh

Have you tried replacing update.sh with something like a say command for testing it?

@reboot works for me when restarting but not when logging out and back in. @reboot open /test.txt didn't work but * * * * * open /test.txt did.

You could also save a plist like this as ~/Library/LaunchAgents/simplehttpserver.plist:

<?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>simplehttpserver</string>
    <key>ProgramArguments</key>
    <array>
        <string>python</string>
        <string>-m</string>
        <string>SimpleHTTPServer</string>
        <string>8000</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>WorkingDirectory</key>
    <string>/Users/john/Kiosk/app</string>
</dict>
</plist>

It can be loaded with launchctl load ~/Library/LaunchAgents/simplehttpserver.plist or by logging out and back in.

You must log in to answer this question.

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