Joomla 3.9.13

I'm currently working on a website which is currently offline. I need make make it available and online at a certain date / time. I may not be available to do this manually.

Is it possible to schedule this action somehow?

Also, it would be nice if I could easily re-use this action.

I'd prefer not to override any core files or code.

3 Answers 3


You could create a cron job that runs daily and executes a PHP file. You should be able to set this up in your hosting control panel.

Command: php /home/xxx/public_html/cli/sitelive.php

Then go to: https://www.unixtimestamp.com/index.php, add the date you wish to go live and convert it to a UNIX timestamp.


const _JEXEC = 1;

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);

if (file_exists(dirname(__DIR__) . '/defines.php'))
    require_once dirname(__DIR__) . '/defines.php';

if (!defined('_JDEFINES'))
    define('JPATH_BASE', dirname(__DIR__));
    require_once JPATH_BASE . '/includes/defines.php';

require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';

// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';

class SiteLivecron extends JApplicationCli
    public function doExecute()
        // Get date object
        $date = JFactory::getDate();
        $current = $date->toUnix();
        $goLiveDate = YOUR_GENERATED_UNIX_TIMESTAMP; // Edit this line

        if ($current > $goLiveDate)
            $configFile = JPATH_BASE . '/configuration.php';
            $contents = file_get_contents($configFile);

            // Replace the $offline variable
            $replace = str_replace("$offline = '1'", "$offline = '0'", $contents);

            // Save the file
            file_put_contents($configFile, $replace);


Note: I'd suggest giving this a test before

Hope it helps

  • this looks perfect, thanks! Always though this should be a default feature of Joomla..
    – jonboy
    Nov 21, 2019 at 12:31
  • @jonboy Made a quick edit to my answer. I put the 0 and 1 the wrong way round :)
    – Lodder
    Nov 21, 2019 at 14:12

I am assuming you are referring to the $offline field in configuration.php is set to something other than 0 to make your website offline. If your are disabling at a server or .htaccess level then this answer won't be much help.

A fairly simple plugin that stores the date/time you want the site to go online. The plugin will check each time someone visits the site and the first person to visit past the desired date/time will update $offline to '0' and your site is now online.

For a bit more coolness you could have the plugin disable itself once it has been triggered to avoid having it trigger on every page of visitors.

  • 1
    Bare in mind that for a plugin to trigger, someone will have to visit the website. If nobody visits the offline site on that day it needs to go live, then it won't go live
    – Lodder
    Nov 21, 2019 at 11:40

You can do that from the template side. Add this code below in the top of the file ../templates/your_default_template_name/offline.php, after the defined('_JEXEC') or die; part

$currentTime = new JDate();
$siteLive = new JDate('2019-11-21 11:21:36'); // Change to your site live
if($currentTime >= $siteLive ) {
   $str = file_get_contents('configuration.php');
   $str = str_replace("offline = '1';", "offline = '0';",$str);
   file_put_contents('configuration.php', $str);
   echo "<script> location.href='index.php'; </script>";

Note : You probably will need to change the permission of configuration.php into writeable which is may open up a potential security hole. I'd suggest you to change back the permission into unwritable as soon as you can.

  • Thanks for this suggestion, aside from the security concern you mention won't I lose this if I ever update the template?
    – jonboy
    Nov 21, 2019 at 12:41
  • Yes, template update will likely to replace all existing template files. Do you need to do this repeatedly or just once?
    – webchun
    Nov 21, 2019 at 12:45
  • yes I would need to re-use. I've updated my question. Thanks
    – jonboy
    Nov 21, 2019 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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