We’re pleased to announce the addition of crons to the PiCloud platform. A cron is a simple way to schedule a function to be run periodically. Time and dates are specified using the standard crontab format. Crons can be triggered as often as every minute, and there’s no limit to the number of functions you can register as crons. You will be billed for the amount of compute time consumed by the function triggered by your cron–just like if you were running a function on PiCloud. We have also added a tab to the web interface for managing crons.
Here’s how to register a cron:
# registers function ping_webserver with the label heartbeat # this function could be checking whether a webservice is active cloud.cron.register(ping_webserver, 'heartbeat', '* * * * *') # runs every minute
When you no longer need a cron, you can deregister it via our web interface or using the following:
# deregister function ping_webserver with the label heartbeat cloud.cron.deregister('ping_webserver')
Here’s a function that runs once a day at noon.
# 19 is the 19th GMT hour, which translates to 12pm PDT (GMT -7) cloud.cron.register(sudo_make_me_a_sandwich, 'lunch', '0 19 * * *')
That’s all it takes! See our documentation for the full cron specification.
Categories: What's NewYou can follow any responses to this entry through the RSS 2.0 feed.