Jump to content

A Cron Run For Every Day Of The Week


Byron

Recommended Posts

Since we only allow 2 cron jobs a day here at heliohost, here's a way to get 7 different cron jobs while only using one of your allowed cron jobs. I wrote this simple script to use on my site to clear old files in several directories. Make a php file and call it something like curl-cron.php and add the code below to that file, then set your cron job to run it every 24 hours. :

 

<?php

$today = date("w");
$url = array( 
"http://sunday_cron_job.php",
"http://monday_cron_job.php",
"http://tuesday_cron_job.php",
"http://wednesday_cron_job.php",
"http://thurdsay_cron_job.php",
"http://friday_cron_job.php",
"http://saturday_cron_job.php"
  );

$url = $url[$today];

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
curl_close($ch);
?>

 

Now you can replace each day of the week with a different cron job.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...