Bios Clock



  • Hello everyone, I've got a problem with my bios clock keep resetting each time my machine shutdown.  I have cron schedule my system shutdown @ 1:45am and have my bios set to wake up by alarm at 6:30am but somehow the clock in there bios keep resetting and my machine won't trun on.  I've troubleshoot everything on the hardware including changing the bios battery but the time still reset.  I'm running 1.2.2 rc3 pfsense with the time set to America/Los Angeles.  Would it be the software side that would change the time in the bio?  Please advise thank you.


  • Rebel Alliance Developer Netgate

    If your system is losing the time when shut off, that would be hardware.

    pfSense will set the clock via NTP once the WAN link comes up, which will be set in the BIOS at that point, but the time you are using is purely in the BIOS while it's turned off.



  • Older board?  Battery!


  • Rebel Alliance Developer Netgate

    @chpalmer:

    Older board?   Battery!

    In his initial post, he stated that the battery had been changed.

    That said, you may want to test the voltage on the "new" battery to be sure it's putting out >3V. Or just replace it with a new, fresh battery from a retail package (not one pulled from another board).



  • The board is an "Abit IC7-Max3" Pentium 4 @3.2Ghz /w 2gigabyte ddr ram.  I've tested the battery on the board at 3.2v and had ran a couple of tested repeatedly just to make sure it wasn't any hardware issue and i'm sure that it's not the hardware that is causing this problem.  This is what i did, i have set the corrected time in the bios and saved it.  I than restarted the pc into the bios and check the time to see if it anything changes and it didn't it stay correct.  I did this like 3x without booting up in pfsense and the time in the bios stayed the same as i corrected before.  I'd also turn off the pc using the power button 3x without letting it boot up into pfsense as well and have checked the time in the bios to be correct too.  After running those test successfully i boot it up into pfsese than shut down the pc and check the time in the bios and surely the time have changed.  So the conclusion is that something in pfsense is changing the time in the bios and i'm not sure what might be causing this problem.  Application i have installed in pfsense are: cron, havp, widget, snort, vnstat.  If anyone have any idea please let me know.  Thank you guys i appreciate all the help i can get.



  • Things I would do.

    /system.php
    Check time zone.

    /status.php
    Shows the current time
    DMESG shows what happens at boot.

    Boot from live cd and if the change also happens there I would look for a bios update.



  • Please have a look as i'm not really sure if it's looking right. These are my system.php and status.php.  Thanks again guys.

    System.php

    
    /* $Id$ */
    /*
    	system.php
    	part of m0n0wall (http://m0n0.ch/wall)
    
    	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
    	All rights reserved.
    
    	Redistribution and use in source and binary forms, with or without
    	modification, are permitted provided that the following conditions are met:
    
    	1\. Redistributions of source code must retain the above copyright notice,
    	   this list of conditions and the following disclaimer.
    
    	2\. Redistributions in binary form must reproduce the above copyright
    	   notice, this list of conditions and the following disclaimer in the
    	   documentation and/or other materials provided with the distribution.
    
    	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    	POSSIBILITY OF SUCH DAMAGE.
    */
    
    require("guiconfig.inc");
    
    $pconfig['hostname'] = $config['system']['hostname'];
    $pconfig['domain'] = $config['system']['domain'];
    list($pconfig['dns1'],$pconfig['dns2']) = $config['system']['dnsserver'];
    
    $pconfig['dnsallowoverride'] = isset($config['system']['dnsallowoverride']);
    $pconfig['username'] = $config['system']['username'];
    if (!$pconfig['username'])
    	$pconfig['username'] = "admin";
    $pconfig['webguiproto'] = $config['system']['webgui']['protocol'];
    if (!$pconfig['webguiproto'])
    	$pconfig['webguiproto'] = "http";
    $pconfig['webguiport'] = $config['system']['webgui']['port'];
    $pconfig['timezone'] = $config['system']['timezone'];
    $pconfig['timeupdateinterval'] = $config['system']['time-update-interval'];
    $pconfig['timeservers'] = $config['system']['timeservers'];
    $pconfig['theme'] = $config['system']['theme'];
    
    if (!isset($pconfig['timeupdateinterval']))
    	$pconfig['timeupdateinterval'] = 300;
    if (!$pconfig['timezone'])
    	$pconfig['timezone'] = "Etc/UTC";
    if (!$pconfig['timeservers'])
    	$pconfig['timeservers'] = "pool.ntp.org";
    
    $changedesc = "System: ";
    $changecount = 0;
    
    function is_timezone($elt) {
    	return !preg_match("/\/$/", $elt);
    }
    
    if($pconfig['timezone'] <> $_POST['timezone']) {
    	/* restart firewall log dumper helper */
    	require_once("functions.inc");
    	$pid = `ps awwwux | grep -v "grep" | grep "tcpdump -v -l -n -e -ttt -i pflog0"  | awk '{ print $2 }'`;
    	if($pid) {
    		mwexec("kill $pid");
    		usleep(1000);
    	}		
    	filter_pflog_start();
    }
    
    exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
    $timezonelist = array_filter($timezonelist, 'is_timezone');
    sort($timezonelist);
    
    if ($_POST) {
    
    	$changecount++;
    
    	unset($input_errors);
    	$pconfig = $_POST;
    
    	/* input validation */
    	$reqdfields = split(" ", "hostname domain username");
    	$reqdfieldsn = split(",", "Hostname,Domain,Username");
    
    	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
    
    	if ($_POST['hostname'] && !is_hostname($_POST['hostname'])) {
    		$input_errors[] = "The hostname may only contain the characters a-z, 0-9 and '-'.";
    	}
    	if ($_POST['domain'] && !is_domain($_POST['domain'])) {
    		$input_errors[] = "The domain may only contain the characters a-z, 0-9, '-' and '.'.";
    	}
    	if (($_POST['dns1'] && !is_ipaddr($_POST['dns1'])) || ($_POST['dns2'] && !is_ipaddr($_POST['dns2']))) {
    		$input_errors[] = "A valid IP address must be specified for the primary/secondary DNS server.";
    	}
    	if ($_POST['username'] && !preg_match("/^[a-zA-Z0-9]*$/", $_POST['username'])) {
    		$input_errors[] = "The username may only contain the characters a-z, A-Z and 0-9.";
    	}
    	if ($_POST['webguiport'] && (!is_numericint($_POST['webguiport']) ||
    			($_POST['webguiport'] < 1) || ($_POST['webguiport'] > 65535))) {
    		$input_errors[] = "A valid TCP/IP port must be specified for the webGUI port.";
    	}
    	if (($_POST['password']) && ($_POST['password'] != $_POST['password2'])) {
    		$input_errors[] = "The passwords do not match.";
    	}
    
    	$t = (int)$_POST['timeupdateinterval'];
    	if (($t < 0) || (($t > 0) && ($t < 6)) || ($t > 1440)) {
    		$input_errors[] = "The time update interval must be either 0 (disabled) or between 6 and 1440.";
    	}
    	foreach (explode(' ', $_POST['timeservers']) as $ts) {
    		if (!is_domain($ts)) {
    			$input_errors[] = "A NTP Time Server name may only contain the characters a-z, 0-9, '-' and '.'.";
    		}
    	}
    
    	if (!$input_errors) {
    		update_if_changed("hostname", $config['system']['hostname'], strtolower($_POST['hostname']));
    		update_if_changed("domain", $config['system']['domain'], strtolower($_POST['domain']));
    		update_if_changed("username", $config['system']['username'], $_POST['username']);
    
    		if (update_if_changed("webgui protocol", $config['system']['webgui']['protocol'], $_POST['webguiproto']))
    			$restart_webgui = true;
    		if (update_if_changed("webgui port", $config['system']['webgui']['port'], $_POST['webguiport']))
    			$restart_webgui = true;
    
    		update_if_changed("timezone", $config['system']['timezone'], $_POST['timezone']);
    		update_if_changed("NTP servers", $config['system']['timeservers'], strtolower($_POST['timeservers']));
    		update_if_changed("NTP update interval", $config['system']['time-update-interval'], $_POST['timeupdateinterval']);
    
    		/* pfSense themes */
    		update_if_changed("System Theme", $config['theme'], $_POST['theme']);
    
    		/* XXX - billm: these still need updating after figuring out how to check if they actually changed */
    		unset($config['system']['dnsserver']);
    		if ($_POST['dns1'])
    			$config['system']['dnsserver'][] = $_POST['dns1'];
    		if ($_POST['dns2'])
    			$config['system']['dnsserver'][] = $_POST['dns2'];
    
    		$olddnsallowoverride = $config['system']['dnsallowoverride'];
    
    		unset($config['system']['dnsallowoverride']);
    		$config['system']['dnsallowoverride'] = $_POST['dnsallowoverride'] ? true : false;
                    if ($_POST['password']) {
                            $config['system']['password'] = crypt($_POST['password']);
    			update_changedesc("password changed via webConfigurator");
    			sync_webgui_passwords();
                    }
    
    		if ($changecount > 0)
    			write_config($changedesc);
    
    		if ($restart_webgui) {
    			global $_SERVER;
    			list($host) = explode(":", $_SERVER['HTTP_HOST']);
    			if ($config['system']['webgui']['port']) {
    				$url="{$config['system']['webgui']['protocol']}://{$host}:{$config['system']['webgui']['port']}/system.php";
    			} else {
    				$url = "{$config['system']['webgui']['protocol']}://{$host}/system.php";
    			}
    		}
    
    		$retval = 0;
    		config_lock();
    		$retval = system_hostname_configure();
    		$retval |= system_hosts_generate();
    		$retval |= system_resolvconf_generate();
    		$retval |= system_password_configure();
    		$retval |= services_dnsmasq_configure();
    		$retval |= system_timezone_configure();
    		$retval |= system_ntp_configure();
    
    		if ($olddnsallowoverride != $config['system']['dnsallowoverride'])
    			$retval |= interfaces_wan_configure();
    
    		config_unlock();
    
    		// Reload filter -- plugins might need to run
    		filter_configure();
    
    		$savemsg = get_std_save_message($retval);
    		if ($restart_webgui)
    			$savemsg .= "
    One moment...redirecting to {$url} in 10 seconds.";
    	}
    }
    
    $pgtitle = "System: General Setup";
    include("head.inc");
    
    ?>
    
    <form action="system.php" method="post">
    
    | Hostname |  
    
     name of the firewall host, without
                        domain part
    
                        e.g. _firewall_ |
    | Domain |  
    
     e.g. _mycorp.com_  |
    | DNS servers |  
    
                          IP addresses; these are also used for
                          the DHCP service, DNS forwarder and for PPTP VPN clients
    
                          >
                          **Allow DNS server list to be overridden by DHCP/PPP
                          on WAN**
    
                          If this option is set,  will use DNS servers assigned
                          by a DHCP/PPP server on WAN for its own purposes (including
                          the DNS forwarder). They will not be assigned to DHCP and
                          PPTP VPN clients, though.
    
     |
    | Username |  
    
                         If you want
                        to change the username for accessing the webGUI, enter it
                        here. |
    | Password |  
    
                         (confirmation) 
     If you want
                        to change the password for accessing the webGUI, enter it
                        here twice. |
    | webGUI protocol |  >
                        HTTP     >
                        HTTPS |
    | webGUI port |  
    
                        Enter a custom port number for the webGUI
                        above if you want to override the default (80 for HTTP, 443
                        for HTTPS). Changes will take effect immediately after save. |
    | Time zone |  <select name="timezone" id="timezone">                                            <option value="<?=htmlspecialchars($value);?>" <?php="" if="" ($value="=" $pconfig['timezone'])="" echo="" "selected";="" ?="">></option>                                           </select> 
     Select the location closest
                        to you |
    | NTP time server |  
    
     Use a space to separate multiple
                        hosts (only one required). Remember to set up at least one
                        DNS server if you enter a host name here! |				
    					   |								
    					 Theme |								
    				   |				 
    				    <select name="theme">$files = return_dir_as_array("/usr/local/www/themes/");				foreach($files as $f) {					if ( (substr($f, 0, 1) == "_") && !isset($config['system']['developer']) ) continue;					if($f == "CVS") continue;					$selected = "";					if($f == $config['theme'])						$selected = " SELECTED";					if($config['theme'] == "" and $f == "pfsense")						$selceted = " SELECTED";					echo "\t\t\t\t\t"."{$f}\n";				}?></select> 
    					**This will change the look and feel of** 
    				 |								
    |   |  
                       |
    
    </form>
    
    	// restart webgui if proto or port changed
    	if ($restart_webgui) {
    		echo "";
    	}
    ?>
    
    if ($restart_webgui) {
    	touch("/tmp/restart_webgui");
    }
    ?></mk@neon1.net>
    

    Status.php

    
    /* $Id$ */
    /* Run various commands and collect their output into HTML tables.
     * Jim McBeath <jimmc@macrovision.com>Nov 2003
     *
     * (modified for m0n0wall by Manuel Kasper <mk@neon1.net>)
     * (modified for pfSense by Scott Ullrich geekgod@pfsense.com)
     */
    
    /* Execute a command, with a title, and generate an HTML table
     * showing the results.
     */
    
    /* include all configuration functions */
    require_once("guiconfig.inc");
    require_once("functions.inc");
    
    function doCmdT($title, $command) {
        echo "
    
    \n";
        echo "<a name="\&quot;&quot;" .="" $title="" "\"="">\n";
        echo "\n";
        echo "\n";
        echo "\n";
        echo "
    
    | " . $title . " |
    | ```
    ";		/* no newline after pre */
    
    	if ($command == "dumpconfigxml") {
    		$fd = @fopen("/conf/config.xml", "r");
    		if ($fd) {
    			while (!feof($fd)) {
    				$line = fgets($fd);
    				/* remove sensitive contents */
    				$line = preg_replace("/<password>.*?<\\/password>/", "<password>xxxxx</password>", $line);
    				$line = preg_replace("/<pre-shared-key>.*?<\\/pre-shared-key>/", "<pre-shared-key>xxxxx</pre-shared-key>", $line);
    				$line = preg_replace("/<rocommunity>.*?<\\/rocommunity>/", "<rocommunity>xxxxx</rocommunity>", $line);
    				$line = str_replace("\t", "    ", $line);
    				echo htmlspecialchars($line,ENT_NOQUOTES);
    			}
    		}
    		fclose($fd);
    	} else {
    		$execOutput = "";
    		$execStatus = "";
    		exec ($command . " 2>&1", $execOutput, $execStatus);
    		for ($i = 0; isset($execOutput[$i]); $i++) {
    			if ($i > 0) {
    				echo "\n";
    			}
    			echo htmlspecialchars($execOutput[$i],ENT_NOQUOTES);
    		}
    	}
        echo "</rocommunity></pre-shared-key></password>
    ``` |
    
    \n";
    }
    
    /* Execute a command, giving it a title which is the same as the command. */
    function doCmd($command) {
        doCmdT($command,$command);
    }
    
    /* Define a command, with a title, to be executed later. */
    function defCmdT($title, $command) {
        global $commands;
        $title = htmlspecialchars($title,ENT_NOQUOTES);
        $commands[] = array($title, $command);
    }
    
    /* Define a command, with a title which is the same as the command,
     * to be executed later.
     */
    function defCmd($command) {
        defCmdT($command,$command);
    }
    
    /* List all of the commands as an index. */
    function listCmds() {
        global $commands;
        echo "</a>
    
    <a name="\&quot;&quot;" .="" $title="" "\"="">This status page includes the following information:\n";
        echo "</a>
    
    <a name="\&quot;&quot;" .="" $title="" "\"="">\n";
        for ($i = 0; isset($commands[$i]); $i++ ) {
            echo "</a>
    *   <a name="\&quot;&quot;" .="" $title="" "\"=""></a>**[" . $commands[$i][0] . "](\"#")**\n";
            }
            echo "
    
    \n";
    }
    
    /* Execute all of the commands which were defined by a call to defCmd. */
    function execCmds() {
        global $commands;
        for ($i = 0; isset($commands[$i]); $i++ ) {
            doCmdT($commands[$i][0], $commands[$i][1]);
        }
    }
    
    global $g;
    
    /* Set up all of the commands we want to execute. */
    defCmdT("System uptime","uptime");
    defCmdT("Interfaces","/sbin/ifconfig -a");
    
    defCmdT("Routing tables","netstat -nr");
    
    defCmdT("top | head -n5", "/usr/bin/top | /usr/bin/head -n5");
    
    defCmdT("sysctl hw.physmem","/sbin/sysctl hw.physmem");
    
    defCmdT("ipfw show", "/sbin/ipfw show");
    defCmdT("pfctl -sn", "/sbin/pfctl -sn");
    defCmdT("pfctl -sr", "/sbin/pfctl -sr");
    defCmdT("pfctl -ss", "/sbin/pfctl -ss");
    defCmdT("pfctl -si", "/sbin/pfctl -si");
    defCmdT("pfctl -sa"," /sbin/pfctl -sa");
    defCmdT("pfctl -s rules -vv","/sbin/pfctl -s rules -vv");
    defCmdT("pfctl -s queue -v","/sbin/pfctl -s queue -v");
    defCmdT("pfctl -s nat -v","/sbin/pfctl -s nat -v");
    
    defCmdT("netstat -s -ppfsync","netstat -s -ppfsync");
    
    defCmdT("pfctl -vsq","/sbin/pfctl -vsq");
    
    defCmdT("pfctl -vs Tables","pfctl -vs Tables");
    
    defCmdT("Load Balancer","/sbin/pfctl -a slb -s nat");
    
    defCmdT("pftop -w 150 -a -b","/usr/local/sbin/pftop -a -b");
    defCmdT("pftop -w 150 -a -b -v long","/usr/local/sbin/pftop -w 150 -a -b -v long");
    defCmdT("pftop -w 150 -a -b -v queue","/usr/local/sbin/pftop -w 150 -a -b -v queue");
    defCmdT("pftop -w 150 -a -b -v rules","/usr/local/sbin/pftop -w 150 -a -b -v rules");
    defCmdT("pftop -w 150 -a -b -v size","/usr/local/sbin/pftop -w 150 -a -b -v size");
    defCmdT("pftop -w 150 -a -b -v speed","/usr/local/sbin/pftop -w 150 -a -b -v speed");
    
    defCmdT("resolv.conf","cat /etc/resolv.conf");
    
    defCmdT("Processes","ps xauww");
    defCmdT("dhcpd.conf","cat /var/etc/dhcpd.conf");
    defCmdT("ez-ipupdate.cache","cat /conf/ez-ipupdate.cache");
    
    defCmdT("df","/bin/df");
    
    defCmdT("racoon.conf","cat /var/etc/racoon.conf");
    defCmdT("SPD","/usr/local/sbin/setkey -DP");
    defCmdT("SAD","/usr/local/sbin/setkey -D");
    
    defCmdT("last 200 system log entries","/usr/sbin/clog /var/log/system.log 2>&1 | tail -n 200");
    defCmdT("last 50 filter log entries","/usr/sbin/clog /var/log/filter.log 2>&1 | tail -n 50");
    
    defCmd("ls /conf");
    defCmd("ls /var/run");
    
    defCmd("/sbin/mount");
    
    defCmdT("cat {$g['tmp_path']}/rules.debug","cat {$g['tmp_path']}/rules.debug");
    
    defCmdT("VMStat", "vmstat -afimsz");
    
    defCmdT("config.xml","dumpconfigxml");
    
    defCmdT("DMESG","/sbin/dmesg -a");
    
    defCmdT("netstat -mb","netstat -mb");
    defCmdT("vmstat -z","vmstat -z");
    
    exec("/bin/date", $dateOutput, $dateStatus);
    $currentDate = $dateOutput[0];
    
    $pgtitle = $g['product_name'] . ": status";
    include("head.inc");
    
    ?>
    
    **Note: make sure to remove any sensitive information
    (passwords, maybe also IP addresses) before posting
    information from this page in public places (like mailing lists)!**
    
    Passwords in config.xml have been automatically removed.</mk@neon1.net></jimmc@macrovision.com> 
    

Log in to reply