Skygear supports creating functions that run at specific time intervals using
@skygear.every decorator. It works similar to the
cron daemon in UNIX.
# cron job that runs every 2 minutes def meow_for_food(): # Skygear Portal Console Log will show 'Meow Meow!' every 2 minutes log.info('Meow Meow!')
The decorator takes one argument, the
interval, which specifies the
time at which the function should be invoked.
Some examples of
interval values are shown below. For detailed
specifications, you can refer to the cron library for go,
which is the parser used in Skygear.
@every(the last two examples above), the interval will be reset upon the re-deployment of cloud code. For instance, an existing scheduled task running at 1-hour interval
@skygear.every('every 1h')will be run 1 hour after the re-deployment, meaning that the actual interval will be longer than 1 hour due to the re-deployment.