Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I run a PHP script every few seconds in Ubuntu Server? (bonus: How can I run random within the cron script, e.g. every 3 seconds + random(3 seconds) )

share|improve this question
I'd recommend that you first evaluate whether you actually need such short intervals. There's a reason they are discouraged, after all. – user98085 Aug 19 '13 at 21:40
What you are asking to do appears like it's a bad idea - in order to satisfy us that you know what you are doing, could you please give some more information about why you want to do this? What is your application? – thomasrutter Jun 17 '14 at 1:14

cron only runs at intervals of one minute or longer. If you really need, you could create a script of some sort that repeats whatever needs doing in a loop and sleeps for 3 seconds between iterations. But There's likely a better means to whatever ends you're actually trying to achieve.

share|improve this answer
you mean a minimum – Max Aug 19 '13 at 21:32
How would such a script look? – Max Aug 19 '13 at 21:38
Something along the lines of while(true){do_something();sleep(3);}. – Kevin Aug 19 '13 at 21:41
Which would work, but again OP, this is probably a bad idea - we need to know more about what your application/goal is. – thomasrutter Jun 17 '14 at 1:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.