1

This question already has an answer here:


It's possible to set the cron job tool in my website cpanel 'VPS Hosting' to execute php file every 30 second
I am using it to execute php file once at a minute *,*,*,*,* but I need to set it to run twice in minute
I have tried 1/2,*,*,*,* but it's not working.

marked as duplicate by Marco, Jenny D, chaos, Anthon, Archemar May 26 '15 at 11:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • To keep it precisely, not a dublicate; it's 30 seconds not 15 ;-) ^^ – chaos May 26 '15 at 11:01
  • i provide a different answer than given here or at the every-15-second question. See unix.stackexchange.com/a/205717/105631 – Otheus May 26 '15 at 16:22
1

Why don't you run a shell script which runs your command, like:

#!/bin/tcsh -f
start:
mycommand >> /tmp/output
sleep 30
goto start

As someone else said, cron has a granularity of 1 minute.

  • Ned64, IMHO will be good to create your script proof from more than one run. Otherwise will become very interesting DoS tool :) – Romeo Ninov May 26 '15 at 10:53
  • Romeo, Yes, that would be a nice feature. If the command is executed manually, though, and not called by cron, it could be OK. Let's see what Ashraf thinks. – Ned64 May 26 '15 at 10:55
  • If you want an easy way to proof the script from running with multiple instances, you can use flock as is demonstrated here. This is Bash of course. – Justin Frahm May 26 '15 at 11:19
3

You can't exec cron with increment less than minute. You can search for other schedulers. Or consider to create daemon which will have internal scheduler for such interval

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