1

I have an application written in PHP and MySQL. There I need to activate calendar on a specific and again deactivate that calendar on other specified date. This process will occurs once in a year gap between 2 dates is approx 1.5 months.

how should I do this in PHP? Should I use cron jobs?

user3100533
  • 505
  • 2
  • 8
  • 20
  • I recommend you to check the following question answer, which merges the cron-tasks with the PHP code logic. http://stackoverflow.com/questions/13259530/using-cron-jobs-to-visit-url – SaidbakR Feb 08 '14 at 19:58

2 Answers2

1

Having your requirements, I think it would be more stable to add the check "should I show the calendar" into the source code itself. When the check is well written, it should not consume measurable response time.

Having the cron job, you always will have to look at an additional thing. This could be forgotton or whatever. Have experienced that too often ;)

Example for a code that checks that:

$now = new DateTime();
if($now >= new DateTime('14 Mar') && $now < new DateTime('15 May')) {
    show_calendar();
}
hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • I agree with you, as on shared server cron job resources consumption is also 1 issue which need to be continuous monitoring. And the process in once in year it may be unintentionally miss. But can't get your suggestion, it would be very nice if you put more lights on your thought – user3100533 Feb 08 '14 at 20:14
  • To be more precise actually this a admission process which take place between Mid of March to Mid of May (tentative) now this form should not active or you may say it should be hidden before admission starting date and again it should deactivate or hidden after the admission process. Is this possible. Or if there is any way to give the control to user they can activate or deactivate this form. – user3100533 Feb 08 '14 at 20:21
0

I would go with the approach hek2mgl has suggested.

or, if you want to set up a cron job then here is the url you should be using to execute your script on given time:

/usr/bin/php5 /your/directory/path/cron_script.php

To check the path:

Create an index.php in your root folder.

<?php
  var_dump(dirname(__FILE__));
?>

Hope this help.

Dharmesh
  • 52
  • 1
  • 6