PCで巨大なフラッシュアプリを実行しています。PC は常にオンで、約 1 週間後に Chrome がクラッシュします (メモリ リーク - プログラムが大きすぎて再コーディングできません)。毎日指定した時間に自動で再起動する方法はありますか?
よろしくルーベン
PCで巨大なフラッシュアプリを実行しています。PC は常にオンで、約 1 週間後に Chrome がクラッシュします (メモリ リーク - プログラムが大きすぎて再コーディングできません)。毎日指定した時間に自動で再起動する方法はありますか?
よろしくルーベン
これは 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>
Windows を使用していると仮定すると、Windows タスク スケジューラを使用して、毎日のタスクを作成できます。プログラムまたはバッチ スクリプトを実行するタスクを指定できます。
詳細については、http://support.microsoft.com/kb/308569をご覧ください。
Linux/Unix では、cronjob を使用できます。
編集: バッチ スクリプトを使用する場合は、chrome が既に実行されているかどうかをテストすることもできます。繰り返しますが、このソリューションは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
)