Skip to content
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

cronie doesn't have the proper environment variables set #5510

Closed
Neo-Oli opened this issue Jul 10, 2020 · 13 comments
Closed

cronie doesn't have the proper environment variables set #5510

Neo-Oli opened this issue Jul 10, 2020 · 13 comments
Labels
bug report Something is not working properly

Comments

@Neo-Oli
Copy link
Member

Neo-Oli commented Jul 10, 2020

Problem description
When a cronjob with cronie is run only the following environment variables are set

USER=u0_a84
HOME=/data/data/com.termux/files/home
LOGNAME=u0_a84
PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
LANG=en_US.UTF-8
SHELL=/data/data/com.termux/files/usr/bin/sh
PWD=/data/data/com.termux/files/home

Busybox's crond used to just set the enivronment variables that it was started with including the very important BOOTCLASSPATH, ANDROID_DATA, LD_PRELOAD, $PREFIX, ANDROID_ROOT, TZ and TMPDIR that some programs, most notably termux-api commands, require to run.

Steps to reproduce
Create a cronjob that runs any termux-api command like termux-vibrate.
To get environment variables create a cronjob containing env > $HOME/environment and read that file.

Expected behavior
The environment variables that termux programs need to run and are set by default should also be set in cronie cronjobs

@Neo-Oli Neo-Oli added the bug report Something is not working properly label Jul 10, 2020
ghost pushed a commit that referenced this issue Jul 10, 2020
@ghost
Copy link

ghost commented Jul 10, 2020

Thanks, that should be fixed in 3e2a16f.

@Neo-Oli
Copy link
Member Author

Neo-Oli commented Jul 10, 2020

Hmm... I can't actually get to run any cronjobs with this new version. Does it still work for you?

@ghost
Copy link

ghost commented Jul 10, 2020

Ok, will check it. Also need to add TZ and LD_PRELOAD to kept variables list.

Note that crond writes info to syslog. If there issues, you can try to look logcat | grep cron.

@Neo-Oli
Copy link
Member Author

Neo-Oli commented Jul 10, 2020

Nothing special in the logcat. It claims it is running the cronjobs but nothing is actually happening. When downgrading to 1.5.5 they run as expected. The logcat is the same for both versions.

@ghost
Copy link

ghost commented Jul 10, 2020

@Neo-Oli I have found issue. We have regression in ndk-headers, someone removed patch for _PATH_DEFPATH which results in incorrect PATH setting for crond.

Now it picks binaries from /system/bin, but not from $PREFIX/bin.

@ghost
Copy link

ghost commented Jul 10, 2020

Works now, tested with crontab * * * * * termux-notification -t "$(date)".

@ghost ghost closed this as completed Jul 10, 2020
@Neo-Oli
Copy link
Member Author

Neo-Oli commented Jul 10, 2020

@xeffyr I can confirm that it works now. Thanks for looking into this.

@Shivam623
Copy link

Hi, I am using .bashrc file to put my environment variables and it is not working. What I am missing?

@ghost
Copy link

ghost commented Aug 3, 2021

@Shivam623 You are missing that .bashrc is only for interactive shells. Try to put your variables into ~/.profile or ~/.bash_profile instead.

@Shivam623
Copy link

Shivam623 commented Aug 7, 2021

Hi @xeffyr , I tried putting in both of the file but it doesn't work on Termux. :(

I tried * * * * * printenv>>envlog.text

I got all the default variables but not the one I set under ~/.profile or ~/.bash_profile.

@Shivam623
Copy link

haha! @xeffyr I am on the same page, trying the suggestions. Fingers cross.

@Shivam623
Copy link

so, * * * * * .$HOME/.profile; python <>/.test.py

this worked for me. Finally!

Thanks a lot @xeffyr

@ghost ghost locked and limited conversation to collaborators Oct 9, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug report Something is not working properly
Projects
None yet
Development

No branches or pull requests

2 participants