termux / termux/termux-api

termux-job-scheduler random scheduling on some devices

Open
#742 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.3k
Forks
920
PR merge metrics
No merged PRs in 30d

Description

Problem description

I have the same set up on a number of different Samsung devices. A scheduled job that runs a bash script (test.sh) which simply writes the result of the "date" command to a file.

The results of using the termux-job-scheduler tool seem to fall into one of two camps across these devices. Either the scheduling is consistent or it is completely random.

The scheduled job is as follows:

Pending Job 0: /data/data/com.termux/files/home/bin/test.sh (periodic: 3600000ms) (persisted) (battery not low) (network: NetworkRequest [ NONE id=0, [ Capabilities: INTERNET&TRUSTED&VALIDATED&NOT_VCN_MANAGED&NOT_BANDWIDTH_CONSTRAINED Uid: 10229 UnderlyingNetworks: Null] ])

Below is the output from an example device (SM-G973F) where the results are consistent:

Thu Jan 16 00:03:25 GMT 2025
Thu Jan 16 01:06:26 GMT 2025
Thu Jan 16 02:06:32 GMT 2025
Thu Jan 16 03:04:38 GMT 2025
Thu Jan 16 04:00:39 GMT 2025
Thu Jan 16 05:03:40 GMT 2025
Thu Jan 16 06:06:32 GMT 2025
Thu Jan 16 07:01:47 GMT 2025
Thu Jan 16 08:01:32 GMT 2025
Thu Jan 16 09:00:18 GMT 2025
Thu Jan 16 10:06:34 GMT 2025
Thu Jan 16 11:03:44 GMT 2025
Thu Jan 16 12:06:38 GMT 2025
Thu Jan 16 13:06:38 GMT 2025
Thu Jan 16 14:06:38 GMT 2025
Thu Jan 16 15:06:38 GMT 2025
Thu Jan 16 16:06:38 GMT 2025
Thu Jan 16 17:06:39 GMT 2025
Thu Jan 16 18:06:38 GMT 2025
Thu Jan 16 19:03:48 GMT 2025
Thu Jan 16 20:03:45 GMT 2025
Thu Jan 16 21:02:37 GMT 2025
Thu Jan 16 22:01:16 GMT 2025
Thu Jan 16 23:01:40 GMT 2025
Fri Jan 17 00:01:17 GMT 2025
Fri Jan 17 01:04:18 GMT 2025
Fri Jan 17 02:00:19 GMT 2025
Fri Jan 17 03:03:20 GMT 2025
Fri Jan 17 04:01:23 GMT 2025
Fri Jan 17 05:01:25 GMT 2025
Fri Jan 17 06:01:28 GMT 2025
Fri Jan 17 07:01:19 GMT 2025
Fri Jan 17 08:01:35 GMT 2025
Fri Jan 17 09:00:30 GMT 2025
Fri Jan 17 10:00:37 GMT 2025
Fri Jan 17 11:01:58 GMT 2025
Fri Jan 17 12:01:38 GMT 2025
Fri Jan 17 13:02:47 GMT 2025

Below is the output from an example device (SM-T725) where the results are completely random:

Thu Jan 16 00:09:33 GMT 2025
Thu Jan 16 00:09:36 GMT 2025
Thu Jan 16 04:10:03 GMT 2025
Thu Jan 16 07:04:08 GMT 2025
Thu Jan 16 10:10:35 GMT 2025
Thu Jan 16 10:10:38 GMT 2025
Thu Jan 16 14:33:30 GMT 2025
Thu Jan 16 14:33:32 GMT 2025
Thu Jan 16 19:01:18 GMT 2025
Thu Jan 16 20:01:23 GMT 2025
Thu Jan 16 21:20:06 GMT 2025
Thu Jan 16 22:01:38 GMT 2025
Thu Jan 16 23:41:18 GMT 2025
Fri Jan 17 01:41:49 GMT 2025
Fri Jan 17 01:41:52 GMT 2025
Fri Jan 17 05:42:19 GMT 2025
Fri Jan 17 05:42:22 GMT 2025
Fri Jan 17 12:15:06 GMT 2025
Fri Jan 17 12:15:10 GMT 2025
Fri Jan 17 13:23:37 GMT 2025

On all devices, Battery Saver is off and both Termux and Termux API have their app battery usage set to "Unrestricted".

Could this be a problem with either Termux or the Termux API, or is it simply the results of an underlying problem with the OS?

I've had a look in the LineageOS and Android issue trackers but can't see anything obvious to me.

Steps to reproduce

Schedule a job to run every hour which writes the date to a log file (see above).

Expected behavior

The job should run consistently every hour (more or less).

Additional information

  • termux application version: 0.118.1 (F-Droid)
  • termux-api application version: 0.50.1 (F-Droid)
  • termux-api package version (installed through apt): 0.58.0-1
  • Android OS version: 15 (LineageOS 22.1)
  • Device model: Various Samsung phones and tablets (see above)

Happy to supply any additional information, or perform additional testing, as required.

Any help or advice is appreciated.

Thanks in advance.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the termux-job-scheduler entry point and reproduce the hourly test.sh schedule on the listed Android and LineageOS devices. Compare the consistent and random logs, then determine whether the behavior originates in Termux, Termux API, or the operating system; done means the cause and a reproducible scope are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, bash, java
Domain
cli, mobile-dev, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.