找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 2984|回复: 5

[分享]OpenWRT 添加 释放内存 按钮

[复制链接]
发表于 2019-10-13 10:59 | 显示全部楼层 |阅读模式

修改 modules/admin-full/luasrc/controller/admin/index.lua 文件

–[[
LuCI – Lua Configuration Interface

Copyright 2008 Steven Barth <steven@midlink.org>

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

$Id: index.lua 7789 2011-10-26 03:04:18Z jow $
]]–

module(“luci.controller.admin.index”, package.seeall)

function index()
local root = node()
if not root.target then
root.target = alias(“admin”)
root.index = true
end

local page = node(“admin”)
page.target = firstchild()
page.title = _(“Administration”)
page.order = 10
page.sysauth = “root”
page.sysauth_authenticator = “htmlauth”
page.ucidata = true
page.index = true

— Empty services menu to be populated by addons
entry({“admin”, “services”}, firstchild(), _(“Services”), 40).index = true

entry({“admin”, “Free_Memory”}, call(“Free_Memory”), _(“Free Memory”), 89)
entry({“admin”, “logout”}, call(“action_logout”), _(“Logout”), 90)
end

function action_logout()
local dsp = require “luci.dispatcher”
local sauth = require “luci.sauth”
if dsp.context.authsession then
sauth.kill(dsp.context.authsession)
dsp.context.urltoken.stok = nil
end

luci.http.header(“Set-Cookie”, “sysauth=; path=” .. dsp.build_url())
luci.http.redirect(luci.dispatcher.build_url())
end
function Free_Memory()
luci.util.exec(“echo 3 > /proc/sys/vm/drop_caches”)
luci.http.redirect(luci.dispatcher.build_url(“admin”, “status”, “overview”))
end


黑色加粗部分。


另在 luci/trunk/luci/luci/po/zh_CN/base.po 最底部添加

msgid “Free_Memory”
msgstr “释放内存”

这样使用中文的时候便能显示中文。


我的恩山、我的无线 The best wifi forum is right here.
发表于 2019-10-13 11:33 | 显示全部楼层
没必要吧 op不占很多内存的
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-10-13 12:04 | 显示全部楼层
echo 3 > /proc/sys/vm/drop_caches会导致数据丢失的。需要用 sync && echo 3 > /proc/sys/vm/drop_caches
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-10-13 13:32 来自手机 | 显示全部楼层
这东西意义不大,反而影响进程加载速度和IO
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2019-10-15 23:18 | 显示全部楼层
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2021-1-21 08:35 | 显示全部楼层
谢楼主和 3 楼, 5楼
128小机器,v2 定时执行很香
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-19 11:22

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表