2012-05-03 73 views
-1

我正在PC上运行一个巨大的Flash应用程序。电脑总是开着,大约一个星期后,Chrome崩溃(内存泄漏 - 程序太大而无法重新编码)。有没有办法在每天的特定时间自动重启?自动重启镀铬

问候 Luben

回答

0

假设你使用的是Windows,你可以使用Windows任务调度程序,并创建一个每日任务。您可以指定任务来运行程序或批处理脚本。

有关更多信息,看看http://support.microsoft.com/kb/308569

Linux/Unix下,你可以使用一个cronjob。

编辑:如果你使用批处理脚本,你也可以测试,如果铬已经在运行。同样,这个解决方案只适用于Windows(其实我只用Win7测试过)。为了测试(在这个例子中记事本)的应用程序,你可以使用下面的代码:

tasklist /nh /fi "imagename eq notepad.exe" | find /i "notepad.exe" >nul && (
    echo Windows Media Player is running 
) || (
    echo Windows Media Player is not running 
) 
0

这可以通过JavaScript来实现。

<script> 

    /* 
    Uncomment below line to test this. 
    alert('We reloaded!'); 
    */ 

    /* Configure when to reload. */ 
    specified_time = [22,30]; /* [hours, minutes] */ 


    is_time_to_reload = function(){ 
     var current_time = new Date(); 

     return (
      (current_time.getHours() >= specified_time[0]) && 
      (current_time.getMinutes() >= specified_time[1]) 
     ); 
    } 

    /* We might have just reloaded. This will avoid 
     reloading again until the time comes tomorrow */ 
    if(is_time_to_reload()){ 
     var not_reload_again_today = true; 
     var last_day_reloaded = (new Date()).getDay(); 
    } 

    check_refresh = function(){ 
     var current_time = new Date(); 

     if (is_time_to_reload()){ 
      if (not_reload_again_today && 
        current_time.getDay() == last_day_reloaded){ 
       return; 
      } else { 
       window.location.reload(); 
      } 
     } 
    } 

    /* check once a minute. */ 
    setInterval(check_refresh, 60 * 1000); 

    </script> 

它也可以通过HTML来实现,但你无法控制的装弹时间。

<head> 
     <!-- refresh page every 86400 seconds. --> 
     <meta http-equiv="refresh" content="86400" /> 
    </head>