index.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <link rel="canonical" href="https://jamesfengcao.gitlab.io/uweb/en/tcron/" />
  7. <link rel="stylesheet" href="../style.css#" type="text/css" />
  8. <title>cron</title>
  9. <script>
  10. function findLang(){
  11. let href = location.href;
  12. for(let i=href.length-1;i>0;i--){
  13. if('/'==href.charAt(i) && '/'==href.charAt(i-3))
  14. return i;
  15. }
  16. return 0;
  17. }
  18. function nav2(page){
  19. let i = findLang();
  20. location.href = location.href.substring(0,i+1)+page;
  21. }
  22. function nav2Lang(lang){
  23. let i = findLang();
  24. let href = location.href;
  25. location.href = location.href.substring(0,i-2)+lang+location.href.substring(i);
  26. }
  27. </script>
  28. </head>
  29. <body>
  30. <header class='header'>
  31. <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>
  32. <a class="logo" href="javascript:void(0)" onclick="return nav2Lang('zh')">简体中文</a>
  33. <nav>
  34. </nav>
  35. </header>
  36. <br />
  37. <div class="container">
  38. <h1 class="title">cron
  39. <br>
  40. <span class="subtitle"></span>
  41. </h1>
  42. <ul class="tags">
  43. </ul>
  44. <h4 id="crontab-with-enhanced-semantics">crontab (with enhanced semantics)</h4>
  45. <p>Some battery restrictions on android 13+ may disallow new instance of uweb browser by alarm events. Users can either keep uweb instance (no battery consumption) or remove the restriction for uweb.</p>
  46. <p>For performance, the file &quot;crontab&quot; uses single space as field separator. Letters are not suppored currently. So use &quot;1&quot; for &quot;January&quot; and 2 for &quot;Tuesday&quot; etc.</p>
  47. <p>The sixth field in crontab file could be in the format of <a href="../links/index.html#">internal links</a>. Specifically, &quot;c:&quot; to execute the following commands in termux and &quot;!&quot; to execute commands directly. If the sixth field is not in any of above formats, then the field will appear as the message of alarm clock.</p>
  48. <p>To make crontab more powerful, we changed the semantics as follows:<br>
  49. The day of a command's execution can be specified by two fields — day of month, and day of week. The command will be run when <span style="color:red">both</span> fields matche the current time.</p>
  50. <p>Note (the original crantab semantics):<br>
  51. The day of a command's execution can be specified by two fields — day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time. For example, &quot;30 4 1,15 * 5&quot; would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.</p>
  52. <h5 id="make-crontab-persist-after-os-rebooting">make crontab persist after OS rebooting</h5>
  53. <p>If uweb browser was launched at least once after rebooting, the crontab jobs are scheduled as normal.</p>
  54. <p>To keep crontab take effect without launching uweb browser once:</p>
  55. <ul>
  56. <li>Install the &quot;com.termux.boot&quot; and &quot;com.termux&quot; Apps.</li>
  57. <li>Create an executable file in termux under the folder &quot;~/.termux/boot/&quot; containing the two lines:<br>
  58. #!/data/data/com.termux/files/usr/bin/sh<br>
  59. am broadcast -n info.torapp.uweb/.AlarmReceiver --es uweb.line &quot;&quot;</li>
  60. <li>Launch &quot;com.termux.boot&quot; once.</li>
  61. </ul>
  62. <h4 id="tcron">tcron</h4>
  63. <p>With the option &quot;custom file handling&quot; enabled, &quot;default.rc&quot; runs as shell script at uweb launching time and &quot;default.rc2&quot; runs whenever uweb becomes foreground.</p>
  64. <p>Use tcron (<a href="i:0bhttps://fastly.jsdelivr.net/gh/torappinfo/uwebjs/bin/tcron.tgz">Click to install</a>) with &quot;default.rc&quot; or &quot;default.rc2&quot;.</p>
  65. <p>usage: tcron logfile command hours [timezone delay_sec elsecommand]<br>
  66. execute &quot;command&quot; during time interval once.<br>
  67. where logfile modification time must be updated if &quot;command&quot; runs successfully.</p>
  68. <p>hours: If positive, then each day is divided into multiple intervals (unit: hour), and in each interval, the &quot;command&quot; runs only once.<br>
  69. If negative, then the unit is minute.<br>
  70. hours could be also in &quot;hh:mm-hh:mm,...&quot; format. Ex. &quot;6:00-8:30,11:00-13:00,5:30-6:30&quot;.<br>
  71. timezone: an integer, default to be &quot;8&quot; for Beijing China (UTC+8). &quot;0&quot; for Greenwich UK (UTC+0).<br>
  72. delay_sec: execute &quot;command&quot; after &quot;delay_sec&quot; seconds.<br>
  73. elsecommand: executed whenever &quot;command&quot; not run.</p>
  74. <p>ex:<br>
  75. set PATH=/system/bin:/data/data/info.torapp.uweb/files/bin<br>
  76. #Empty the folder &quot;baidu&quot; every 30 days.<br>
  77. tcron /sdcard/b &quot;rm -rf /sdcard/baidu/*;toybox touch /sdcard/b&quot; 720</p>
  78. <p><a target="_self" href="i:0hdefault.rc:../searchurl/txt/default.rc">Install example default.rc file for termux</a></p>
  79. </div>
  80. <p>Last Modified: 27 August 2024<br>
  81. update ebrowserreadme.md<br>
  82. <pre></pre>
  83. </p>
  84. <script id='jsgiscus'
  85. src='https://giscus.app/client.js'
  86. data-repo="torappinfo/uweb"
  87. data-repo-id="MDEwOlJlcG9zaXRvcnkzMDIyMDU3MjE="
  88. data-category="Announcements"
  89. data-category-id="DIC_kwDOEgNLGc4CQjsh"
  90. data-mapping="title"
  91. data-strict="0"
  92. data-reactions-enabled="1"
  93. data-emit-metadata="0"
  94. data-input-position="top"
  95. data-theme="light"
  96. data-lang="en"
  97. data-loading="lazy"
  98. crossorigin="anonymous" async>
  99. </script>
  100. <footer class="site-footer">
  101. <div class="container">
  102. &copy; 2018-2024 Richard H. Cao
  103. </div>
  104. </footer>
  105. <!-- 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/>. -->
  106. </body>
  107. </html>