Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jun 14 '13 at 12:08

This question came from our site for professional and enthusiast programmers.

3 Answers 3

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
share|improve this answer
    
Sure! It was a typo. Can also be /bin/sh, you can know it typing which sh. –  fedorqui Jun 14 '13 at 11:23
    
Hmm, that's all changed, but the reboot is certainly still having no effect! –  Mild Fuzz Jun 14 '13 at 11:43
    
Have you tried changing open to /bin/open (or... which open result)? –  fedorqui Jun 14 '13 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 '13 at 11:50
    
I have added more content into the question, hopefully this will assist you. –  Mild Fuzz Jun 14 '13 at 12:11

Taking the open command away did the trick

@reboot yourscript.command
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.