hpscool
hpscool

Reputation: 13

How do I run a PHP cronjob every 15 min with 30 sec duration in cPanel?

I have a PHP script like

domain.com/xxx.php

I set a cron to every 15 minutes with a website (cronjob.org), but it only visit to my PHP script and its duration is like 1 to 2 seconds.

But my cronjob needs a 30 seconds duration (must visit my PHP script for 30 seconds and wait for another job). How do I create the PHP script and how do I put it in my cPanel like the following?

domain.com/yyy.php

When I set cronjob with (cronjob.org) for every 15 min to

domain.com/yyy.php

it visits my original PHP script

domain.com/xxx.php

with 30 seconds duration.

Upvotes: 1

Views: 1469

Answers (1)

Ramalingam Perumal
Ramalingam Perumal

Reputation: 1427

In short, cron is not that granular with time. The shortest period you will get is 1 min.

I would use cron to run a script every minute, and make that script run your script four times with a 15-second sleep between runs.

 * * * * * sleep 30; some_job

sleep (30); //sleep for 30 seconds

That way, you get all the benefits of cron as well as your 30 second run period.

Upvotes: 1

Related Questions