1

I posted a question the other day about setting alternative minutes in cron, and i was given a lovely simple answer.

0-59/2 * * * * first_script
1-59/2 * * * * second_script

This worked brilliantly, however i have seen realized that i need my scripts to run quicker than every minute.

I know cron doesn't support seconds, but you can bluff it by using sleep, like so

* * * * * /foo/bar/your_script
* * * * * sleep 15; /foo/bar/your_script
* * * * * sleep 30; /foo/bar/your_script
* * * * * sleep 45; /foo/bar/your_script

So i need to combine the both of these so that i can get them to run alternatively every 15 seconds for instance.

Any ideas?

cosmicsafari
  • 3,949
  • 11
  • 37
  • 56

1 Answers1

2

Ended up with the following code to get my scripts to run in shorter intervals than 1 minute.

* * * * * /usr/bin/php -q /path/to/file/script1.php
* * * * * sleep 15; /usr/bin/php -q /path/to/file/script2.php
* * * * * sleep 30; /usr/bin/php -q /path/to/file/script1.php
* * * * * sleep 45; /usr/bin/php -q /path/to/file/script2.php
cosmicsafari
  • 3,949
  • 11
  • 37
  • 56