About

This is an implementation of a crontab-like system that sends messages to the entire link-set based on a configurable notecard with crontab-like syntax. The purpose is to create a timer that can trigger certain events given a certain time. For that we use a script that reads a crontab-like syntax notecard and then checks every minute whether the conditions in the crontab notecard are satisfied.

Note that the script uses UTC time (as most servers do) such that you will need to convert from SLT to find out what time to trigger the event in SecondLife. Furthermore, the hour in the crontab notecard is specified in 24-hour format (or military time) where, for example, 18 stands for 6PM.

Setup Demonstration Object

  • Create a new primitive.
  • Create a notecard and name it crontab and place it inside the primitive (you can see a reference notecard below).
  • Create a script inside the same primitive and replace the contents with the contents of the cron script.
  • Create another script inside the same primitive and replace the contents with the contents of the collector relay script.

Using in Your Projects

The script will send a configurable message to the link-set once the criteria from the crontab matches the current date-time stamp in UTC time. The collector relay script is just an example that displays some overhead script when the cron script sends a link message.

The cron script sends the message to the entire link-set (to all the primitives that the object is made of). You can intercept that message using the link_message event handler.

For example, suppose that you have a crontab notecard that contains the following line:

23 * * * * it's time

then the cron script will send the message "it's time" to the entire link-set, every hour on minute 23. Then, the object can contain a script such as:

default {
    link_message(integer sender_num, integer num, string str, key id) {
        if(message == "it's time") {
            // do something
        }
    }
}

which will do something when it gets the message "it's time".

Notecard

###########################################################################
# The crontab script can send a linked message to the link set periodically 
# at a specified time. The syntax is similar to the Unix crontab where 
# asterisks * represent any possible value. Contrasted to some crontab 
# implementations, this crontab does not support ranges (1-5) or 
# enumerations (3,4,5) as you can find in some Unix implementation of 
# crontab. However, you can always add as many crontab lines as you wish to 
# be executed at a specified time. The file supports comments starting with
# the hash character "#" which can be placed in-line or at the start. Any 
# text after the hash sign will be ignored.
###########################################################################
#
# *  *  *  *  * message to send to the link-set
# |  |  |  |  |
# |  |  |  |  +-- day of week (0-7) (Sunday=0 or 7)
# |  |  |  +----- month (1-12)
# |  |  +-------- day of month (1-31)
# |  +----------- hour (0-23)
# +-------------- minute (0-59)

# at minute 22 send the message "chime" to the link set
22 * * * * chime

# at hour 18 (6 pm), send the message "hour!" to the link set
0 18 * * * hour!

# every minute send the message "minute tick" to the link set
#* * * * * minute tick

# send the message "it's now Sunday" to the link set, every minute
* * * * 0 it's now Sunday!

# send the message "it's now Sunday" on Sunday at hour 17 (5pm)
0 17 * * 0 it's now Sunday!

Index


secondlife/cron.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.