Advertisement:

Schedule Maintenance Mode Via Cronjob?

Aloittaja brianjw, helmikuu 12, 2008, 10:12:55 IP

« edellinen - seuraava »

brianjw

I am in need of puttin my forums in maintenance at a certain time ONLY one day this entire forever lol. But the time is when I am sleeping. I am doing it then because that is when automatic backups i have set and will be start messing with the database and things. So, I think "cron...job"

How would I do a cronjob and hook it to Maintenance Mode to go on?
If you know the answer, place in step by step instructions. My host is using latest version of cpanel.

SleePy

Have you looked at the ManageServer.php to see how this is done with getting the information from the Settings.php and then saving it back?

To do this though the other way is to edit the file with php by default and edit the maintinance mode variable on or off.
Though you could also do this with multiple Settings.php files and rename or move them as needed and have one of them change the maintinance mode level.



Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Grudge

Probably something like (not working code):

<?php
$new_mode 
= !empty($_GET['off']) ? 1;
require(
'/path/to/SSI.php');
require(
$sourcedir '/Sus-Admin.php'); // This is where updateSettingsFile is on 2.0
$config_changes = array(
  
'maintenance' => $new_mode,
);
updateSettingsFile($config_changes);
?>


Call it something like cron_maintenance.php and set it up as two cron jobs. One pointing to cron_maintenance.php?off=1 (to turn maintenance off) and one pointing to cron_maintenance.php to turn it on.

Obviously stick it in a non-visable directory so random people can't turn it on and off.

Grudge
I'm only a half geek really...

Advertisement: