Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cant add multiple jobs through termux-job-scheduler? #368

Open
ashjas opened this issue Sep 20, 2020 · 3 comments
Open

cant add multiple jobs through termux-job-scheduler? #368

ashjas opened this issue Sep 20, 2020 · 3 comments

Comments

@ashjas
Copy link

ashjas commented Sep 20, 2020

Problem description

scheduling multiple jobs through termux-job-scheduler with persisted option does not add jobs to the queue, instead it just overwrites the previous one.
Steps to reproduce

termux-job-scheduler -s /data/data/com.termux/files/home/script2.sh --persisted true --period-ms 300000 --job-id 1
termux-job-scheduler -s /data/data/com.termux/files/home/script2.sh --persisted true --period-ms 300000 --job-id 2
these commands only lead to the last job scheduled at job-id 2.
Pending Job 2: /data/data/com.termux/files/home/script2.sh (periodic: 900000ms) (persisted) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10288] ])

Expected behavior

there should be two jobs scheduled with job-id 1 and job-id 2 for each scripts.
Additional information

  • Termux application version: 0.99
  • Android OS version: 10
  • Device model: MiA1
@MrFishFinger
Copy link
Contributor

i see similar behaviour. From what i can tell, both of my jobs are being created and are running, its just that the "pending" command is not returning the list of scheduled jobs correctly...

At least in my case, running the "pending" command repeatedly, returns different results:

$ termux-job-scheduler --pending
Pending Job 1: /data/data/com.termux/files/home/script1.sh      (periodic: 86400000ms) (persisted) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10252 AdministratorUids: [] RequestorUid: -1 RequestorPackageName: null] ])

$ termux-job-scheduler --pending
Pending Job 1: /data/data/com.termux/files/home/script1.sh      (periodic: 86400000ms) (persisted) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10252 AdministratorUids: [] RequestorUid: -1 RequestorPackageName: null] ])

$ termux-job-scheduler --pending
Pending Job 0: /data/data/com.termux/files/home/script2.sh      (periodic: 3600000ms) (persisted) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10252 AdministratorUids: [] RequestorUid: -1 RequestorPackageName: null] ])

...
similar behaviour when running the termux-api binary directly:

$ /data/data/com.termux/files/usr/libexec/termux-api JobScheduler  --ez pending true
Pending Job 0: /data/data/com.termux/files/home/script2.sh      (periodic: 3600000ms) (persisted) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10252 AdministratorUids: [] RequestorUid: -1 RequestorPackageName: null] ])

$ /data/data/com.termux/files/usr/libexec/termux-api JobScheduler  --ez pending true
Pending Job 0: /data/data/com.termux/files/home/script2.sh      (periodic: 3600000ms) (persisted) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10252 AdministratorUids: [] RequestorUid: -1 RequestorPackageName: null] ])

$ /data/data/com.termux/files/usr/libexec/termux-api JobScheduler  --ez pending true
Pending Job 1: /data/data/com.termux/files/home/script1.sh      (periodic: 86400000ms) (persisted) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10252 AdministratorUids: [] RequestorUid: -1 RequestorPackageName: null] ])

seems like there could be an issue with the displayPendingJobs method in termux-api, or the underlying jobScheduler.getAllPendingJobs() it uses...

@medram
Copy link

medram commented Nov 17, 2020

I get the same problem once I've updated termux & termux-api, any solution please without downgrade ?

@MrFishFinger
Copy link
Contributor

ive created MR #391 to resolve this issue

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants