Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Run a cron process more than every minute' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Run a cron process more than every minute
Authored by: fds on May 16, '07 07:51:22AM
If your script is essentially running continuously all the time anyway, you might as well keep it all in one script without adding it to cron or launchd as well.

#!/bin/sh
while : ; do
    open /path/to/getpic.app
    sleep 15
done


[ Reply to This | # ]
Calculate sleep time
Authored by: googoo on May 16, '07 09:03:56AM
You could also calculate the sleep time using date and a little math.

#!/bin/sh
while : ; do
    open /path/to/getpic.app
    sleepTime=$((`date +%S`%15))
    sleep $sleepTime
done

This would repeat every 15 seconds forever.

-Mark



[ Reply to This | # ]
Calculate sleep time--Correction
Authored by: googoo on May 16, '07 05:14:56PM
OK. I did not check my code. This version will work.

#!/bin/sh
while : ; do
    open /path/to/getpic.app
    sleepTime=$((15-`date +%S`%15))
    sleep $sleepTime
done

-Mark



[ Reply to This | # ]