Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

Terry Valladon

@Terry Valladon
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • randomly generate a number every X minutes (php)
    T Terry Valladon

    I may be a tad late to the game here but if you are using Linux or Mac this should work fine for your needs. --Terry Valladon $random_number = rand(); // I will let you worry about seeds and stuff, perhaps call your own make_random() function? print('Random number is '.$random_number."\n"); declare(ticks = 1); // Set ticks to one second pcntl_signal(SIGALRM, "signal_handler"); // Installs a signal handler for SIGALARM (works in linux/mac only I think) pcntl_alarm(1200); //trigger alarm in 20 min (60 seconds * 20 min = 1200 seconds) // This is just to keep the script running forever, I would HOPE you would have real code in here rather then just looping endlessly. for(;;) { sleep(1); } function signal_handler($signal) { global $random_number; switch($signal) { case SIGALRM: $random_number = rand(); // New random number, I will let you worry about seeds and stuff, perhaps call your own make_random() function? print('New random number is '.$random_number."\n"); pcntl_alarm(1200); //trigger alarm again in 20 min break; // Exit function and continue normal code execution. } }

    Web Development tutorial question php
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups