Closed darkoverlordofdata closed 5 years ago
I tried adding crond to my boot script, and ended up with multiple cron jobs running. The longer I left it running, the more jobs. When I finally rebooted (it was the only way I could find to stop the proliferation) there were 5 cron jobs running.
I encountered the same issue. Every time I login via ssh, it would start an AndroidRuntime and tried to start [/data/data/com.termux/files/home/.termux/boot/sshd]
02-01 20:05:18.392 2850 4142 I termux-task: [4140] starting: [/data/data/com.termux/files/home/.termux/boot/sshd]
02-01 20:05:19.530 4153 4153 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10081 <<<<<<
02-01 20:05:19.537 4153 4153 D AndroidRuntime: CheckJNI is OFF
02-01 20:05:19.606 4153 4153 D ICU : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
02-01 20:05:19.687 4153 4153 I Radio-JNI: register_android_hardware_Radio DONE
02-01 20:05:19.720 4153 4153 D AndroidRuntime: Calling main entry com.android.commands.am.Am
02-01 20:05:19.726 4153 4153 D AndroidRuntime: Shutting down VM
So I wrote a script to determine the service is running. This is the example:
if ! pgrep "sshd" >/dev/null; then echo "[Starting sshd...]" && sshd && echo "[sshd started...]"; else echo "[sshd is running]"; fi
if ! pgrep "frpc" >/dev/null; then echo "[Starting frpc...]" && (nohup frpc &) && echo "[frpc started...]"; else echo "[frpc is running...]"; fi
I am also getting multiple instances of crond running. Is anyone looking for a fix to this?
I proposed a fix for this issue (pull request #12).
I am running a script that launches a python2 command from termux boot . The python script should write a file then quit (as I understand it).
I think my issue is similar. Instead of writing the file once then quitting, it re writes the file every 10 minutes. I can see this by the file time.
I do not mind that it is running every 10 Minutes but would much prefer it to run once per hour.
I downloaded the latest version on f-droid only 2 days ago , so no fix yet, and I really need this badly.
as a work-around is it possible to change the job reschedule interval?
I have no idea how to apply this patch!
I took weeks to come up with a solution on android and this was the only thing that really worked without requiring me to have super powers. Unfortunately without new APKs, from a user point of view, the bug remains.
Any hope for finding new apk in the near future on f-droid? I am at the final phase of this project and now stuck on this bug! HELP!
Just out of curiosity, does this problem go away if you run your services in the more modern service-supervision style, as opposed to in the daemonize-into-background style?
To use sshd
as an example, I am currently testing the following script for running that service at boot:
termux-wake-lock
exec sshd -D
sshd -D
is the service-supervision way, where the process remains in the foreground and directly parented to the caller (the exec
just avoids leaving the shell process as a middleman).
I'll report back if I notice this or other issues cropping up in this setup.
Thanks to @travislee8964 suggestion. This works out pretty well for me. No more duplicating tasks.
Content of ~/.termux/boot/start-at-boot
#!/data/data/com.termux/files/usr/bin/bash
if ! pgrep "sshd" >/dev/null; then echo "[Starting sshd...]" && sshd && echo "[ssh started...]"; else echo "[ssh is running]"; fi
if ! pgrep "crond" >/dev/null; then echo "[Starting crond...]" && crond && echo "[crond started...]"; else echo "[crond is running]"; fi
if ! pgrep "python3" >/dev/null; then { nohup python3 your_python_file.py & } 1>stdout.txt 2>stderr.txt ; else echo "[python is running]"; fi
Cron gives you more control though. Content of crontab -e:
*/10 * * * * /data/data/com.termux/files/home/run_once_very_ten_mins.sh
and ~/run_once_very_ten_mins.sh
#!/bin/bash
if ! pgrep "python3" >/dev/null; then { nohup python3 your_python_file.py & } 1>stdout.txt 2>stderr.txt ; else echo "[python is running]"; fi
Best.
this is a symptom of the issue https://github.com/termux/termux-boot/issues/20
Here is a workaround.
Sorry for the long delay here! An updated version 0.6 of Termux:Boot has been released which should fix this issue - please let me know if the problem remains in that version!
I'm getting duplicate processes popping up.
My boot starts a php server for codiad ide:
~/.termux/boot/boot.sh:
It runs this simple php server loop:
~/.codiad-run.sh:
The boot script is the only place where I'm invoking codiad-run.sh. Everything runs ok for several minutes after booting, until Codiad dies, and when I check, there are 4 processes runing codiad-run.sh.
I've tried starting it with nohup instread of disown, and I also tried leaving the console connected, but same result.
I'm not sure if this is related; when I start apache2 instead, I see it is also getting duplicated, with multiple copies of
/data/data/com.termux/files/usr/bin/httpd -k start
running. Apache still works, I don't know if it's expecting this behavior or not.