123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="canonical" href="https://jamesfengcao.gitlab.io/uweb/zh/tcron/" />
-
- <link rel="stylesheet" href="../style.css#" type="text/css" />
- <title>定时脚本</title>
- <script>
- function findLang(){
- let href = location.href;
- for(let i=href.length-1;i>0;i--){
- if('/'==href.charAt(i) && '/'==href.charAt(i-3))
- return i;
- }
- return 0;
- }
- function nav2(page){
- let i = findLang();
- location.href = location.href.substring(0,i+1)+page;
- }
- function nav2Lang(lang){
- let i = findLang();
- let href = location.href;
- location.href = location.href.substring(0,i-2)+lang+location.href.substring(i);
- }
- </script>
- </head>
- <body>
- <header class='header'>
- <a class="logo" href="javascript:void(0)" onclick="return nav2('index.html#')">Home</a> <a class="logo" href="javascript:void(0)" onclick="return nav2('tags/index.html#')">Tags</a>
-
-
- <a class="logo" href="javascript:void(0)" onclick="return nav2Lang('en')">English</a>
-
-
- <nav>
- </nav>
- </header>
- <br />
-
- <div class="container">
- <h1 class="title">定时脚本
- <br>
- <span class="subtitle"></span>
- </h1>
- <ul class="tags">
-
- </ul>
- <h4 id="crontab">crontab</h4>
- <p>注意:1. 必须使用单一空格作为分割符。<br>
- 2. 必须同时满足日期及星期的要求(功能增强),crontab标准只要求满足其中一个要求。</p>
- <p>文件"crontab"每行第六部分可为url或<a href="../links/index.html#">内部链接</a>,也可为"c:"通知termux执行后面命令; "!"直接执行命令。其余格式一律作为闹钟提醒时的伴随消息。</p>
- <p>文件"crontab"自动签到例子:<br>
- 5 8,9 * * * i:p1http://m.bookschina.com/ActityDaily/AvSignIn<br>
- 7 9 * * * i:p1http://m.bookschina.com/ActityDaily/AvSignInTakeQuan<br>
- 6 9 * * * i:p1http://m.bookschina.com/UserCenter/SignInApi#action=SignIn<br>
- 8 9 * * * i:p1http://m.bookschina.com/UserCenter/SignInAward#index=1</p>
- <p>其中"i:a1"为对url发起"post"请求。</p>
- <h4 id="tcron">tcron</h4>
- <p>如果勾选“文件预处理”,则uweb启动时运行"default.rc" shell脚本。可与tcron定时管<br>
- 理工具(<a href="i:0bhttps://fastly.jsdelivr.net/gh/torappinfo/uwebjs/bin/tcron.tgz">安装tcron</a>)配合运行定时任务,如存储清理、网页签到等。</p>
- <p>勾选“文件预处理”的情况下,如果存在文件"default.rc2",则在超微浏览器成为前台时,此文件代码被执行。在超微永不退出的情况下,"default.rc"将没有任何执行机会,而"default.rc2"保证即使超微长时间不重启,定时脚本仍可以执行。</p>
- <p>usage: tcron logfile command hours [timezone delay_sec elsecommand]<br>
- 指定时间范围内如果命令没有被执行过,则tcron会执行一次命令。<br>
- 其中logfile可以不记录任何log,成功执行命令以后只需更新一下改动时间即可。<br>
- hours: 如果为正整数,则将每天划分为不同的时间区间(单位小时),每个区间命令只能执行一次。如果为负整数,则取绝对值,并且单位为分钟,保证下一次执行至少间隔这么多分钟。<br>
- hours也可以为"hh:mm-hh:mm,..."格式, 譬如"6:00-8:30,11:00-13:00,5:30-6:30"为每天三餐时间脚本执行一次。<br>
- timezone: 时区:譬如“8”表示北京时间。(默认为8)<br>
- delay_sec: 等待指定秒数后再执行命令,防止命令被集中执行。<br>
- elsecommand: 无需执行命令command时执行。</p>
- <p>ex:<br>
- set PATH=/system/bin:/data/data/info.torapp.uweb/files/bin<br>
- #天翼云每天签到一次<br>
- tcron /sdcard/a "cloudpan189-go sign;toybox touch /sdcard/a" 24<br>
- #每30天清空baidu目录<br>
- tcron /sdcard/b "rm -rf /sdcard/baidu/*;toybox touch /sdcard/b" 720</p>
- <p><a target="_self" href="i:0hdefault.rc:../searchurl/txt/default.rc">安装default.rc模板文件(termux)</a></p>
- <p>可能用到的命令:<br>
- termux中安装remind,可配置各类提醒功能,十分强大。<br>
- apt install remind</p>
- <p>am start -n info.torapp.uweb/.wvActivity -d 'javascript:alert("remind")' #提醒<br>
- 其中-d后面参数可以为任意url包括超微内部"i:" url。</p>
- </div>
- <p>Last Modified: 29 August 2024<br>
- change i:a to be i:p to indicate Post<br>
- <pre></pre>
- </p>
- <script id='jsgiscus'
- src='https://giscus.app/client.js'
- data-repo="torappinfo/uweb"
- data-repo-id="MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
- data-category="Announcements"
- data-category-id="DIC_kwDOEgNLGc4CQjsh"
- data-mapping="title"
- data-strict="0"
- data-reactions-enabled="1"
- data-emit-metadata="0"
- data-input-position="top"
- data-theme="light"
- data-lang="en"
- data-loading="lazy"
- crossorigin="anonymous" async>
- </script>
- <footer class="site-footer">
- <div class="container">
- © 2018-2024 Richard H. Cao
- </div>
- </footer>
- <!-- This document is licensed under the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at <https://www.gnu.org/licenses/>. -->
- </body>
- </html>
|