Termux 切换到后台保持运行(防止进程冻结)

There's more than one way to do it!
https://metacpan.org http://perlmonks.org
回复
头像
523066680
Administrator
Administrator
帖子: 573
注册时间: 2016年07月19日 12:14
联系:

Termux 切换到后台保持运行(防止进程冻结)

帖子 523066680 »

把以前的爬虫(固定延迟,抓取同一个页面)放到旧的小米手机Termux上面跑,一天后发现抓的页面时间点断断续续。
于是另写一个固定延时显示时间的脚本做测试

代码: 全选

# 测试进程是否持续执行
use Date::Format;
STDOUT->autoflush(1);
while (1)
{
    printf "%s\n", time2str( "%H:%M:%S", time() );
    sleep 60;
}
进程切换后台后执行,数小时后查看时间间隔果然不一致,解决方法:
https://wiki.termux.com/wiki/Termux-wake-lock

代码: 全选

termux-wake-unlock
termux-wake-lock and termux-wake-unlock can be used to trigger a wakelock which causes Android not to go into deep sleep.
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客