The first thing that comes to my mind would be a custom launchd daemon.

_________________________
int getRandomNumber()
{
return 4; //chosen by fair dice roll, guaranteed to be random
}