New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to run commands at boot #14
Comments
Creating a .profile script works, or .bash_profile which takes precedence. |
That is like launching your X server in your .profile, not really ideal. I could check each time if the service is running and if not, start it and exit the terminal, but it seems rather fragile. |
I vote for adding cron to the repo. Not sure how feasible that is. |
@iexos It's a nice idea, will think about it! Perhaps something like executing the file @jarrettgilliam There is |
@fornwall Yes that sounds like a good solution. Maybe not just a file, but a folder where you could drop scripts in, though that depends on taste as it could easily be implemented in the boot file. |
I really like the idea of running cronjobs in Termux, but the issue with |
@benjaminoakes we can use external AlarmManager apps for that. But it's required to disable Termux feature |
That would be really nice to have sometimes. Perhaps available by setting an environment variable (for example On July 4, 2016 4:05:47 AM CDT, "Viktor (vit01)" notifications@github.com wrote:
|
@benjaminoakes Just as an FYI, there is a lot of discussion about this in Issue #56 |
Is service too heavy? roland@roland-HP-Compaq-8100-Elite-SFF-PC:~/BBB$ service Usage: service < option > | --status-all | [ service_name [ command | --full-restart ] ] I'm thinking more along the lines of launching postgresql or any other needed service AT BOOT, not at login. In particular something like postgresql would start when the device powers up and any app could then write to the PostgreSQL port. The more I poke at Android the more I can't believe anybody signed off on shipping this platform, especially on 2 in 1 and tablet computers. |
The Termux:Boot add-on (which is currently unreleased) will be a very good solution to this problem. |
I struggled with this during my own setup on Chromebook, and while maybe a little inelegant, this works for my use case. The execution flow prevents inception-like deeply nested calls to proot, but performs a one-time hop on initial app startup so that sshd starts inside a chroot'd environment (if you don't need chroot to auto-invoke, just remove that line). I've tested 3 different (concurrent) open ssh sessions (via FireSSH and Google's NaSSH) without issues.
Note the -f flag is required because of the way the |
@kennwhite I got nested proots when I used your stanza in my .bash_profile. I changed the first conditional to A little OT: is the chroot solely for ergonomic benefit? Thanks for your article; it inspired me to get a chromebook as my primary mobile environment. Very happy with it so far thanks to Termux! |
Termux:Boot add-on is now out. |
Absolutely no need to install/start chroot/proot! The above commentor did this as an added feature for his/her needs. (Now I've got added libraries I don't need!) Just use an incanatation of a if/then pgrep to first check for an already running process of the program you want to run, and if the program/process isn't already running, then execute it. Insert/append the pgrep if/then incanatation to $HOME/.bashrc If you break the bashrc startup causing termux to hang, swipe for the left menu, click new session and modify the new session as fail safe. Move the bashrc (or bash_profile) to a new name and restart termux. |
To be more explicit, kennwhite's script snippet is designated to run two services (or programs), with the second service (or program) dependent upon the first program. (eg. Similar to making sshd dependent upon establishing an ethernet connection.) So the following is all you really need within bashrc, or preferably bash_profile if bash_profile works on your termux install: if ! pgrep -f "crond" >/dev/null; then The reason why bash_profile is preferred, bash_profile is called once during initial login, versus bashrc upon each shell opening. (Will save a few CPU cycles to use bash_profile.) By the way, this forum's code quoting do not preserve white space well at all! As such, just posted the above snippet within quoting to preserve end line characters. |
For anyone attempting to run Node-Red as a daemon using Termux:Boot, it would be a good idea to run the following: I was running into problems where node-red wasn't actually starting properly and doing some debugging found that the environment that Termux:Boot provided wasn't what node-red needed. Node-Red references /usr/bin/env by default which gives a bad environment for Node.js. The above command fixes that to /data/data/com.termux/files/usr/bin/env which allows it to run properly. |
Would it be possible to run commands (like sshd) automatically after the device boots?
The text was updated successfully, but these errors were encountered: