@@ -5,14 +5,17 @@ SCRIPTNAME=termux-job-scheduler
55
66show_usage () {
77 echo " Usage: termux-job-scheduler [options]"
8- echo " Schedule a script to run at specificied time(s)."
9- echo " --script path to the script to be called"
8+ echo " Schedule a script to run at specified intervals."
9+ echo " --pending list pending jobs and exit (default false)"
10+ echo " --cancel-all boolean cancel all pending jobs and exit (default false)"
11+ echo " --cancel boolean cancel given job-id and exit (default false)"
12+ echo " Options for scheduling:"
13+ echo " --script text path to the script to be called"
1014 echo " --job-id int job id (will overwrite any previous job with the same id)"
11- echo " --pending boolean list pending jobs only (default false)"
1215 echo " --period-ms int schedule job approximately every period-ms milliseconds (default 0 means once)"
13- echo " --network run only when this type of network available, default none (any|unmetered|cellular|not_roaming|none)"
14- echo " --battery-not-low boolean run only when battery is not low, default true (at least Androi O)"
15- echo " --storage-not-low boolean run only when storage is not low, default false (at least Androi O)"
16+ echo " --network text run only when this type of network available, default none (any|unmetered|cellular|not_roaming|none)"
17+ echo " --battery-not-low boolean run only when battery is not low, default true (at least Android O)"
18+ echo " --storage-not-low boolean run only when storage is not low, default false (at least Android O)"
1619 echo " --charging boolean run only when charging, default false"
1720 echo " --trigger-content-uri text (at least Android N)"
1821 echo " --trigger-content-flag int default 1, (at least Android N)"
@@ -22,6 +25,9 @@ show_usage () {
2225OPT_SCRIPT=" "
2326OPT_JOB_ID=" "
2427OPT_PENDING=" "
28+ OPT_CANCEL=" "
29+ OPT_CANCEL_ALL=" "
30+
2531OPT_PERIOD_MS=" "
2632OPT_NETWORK=" "
2733OPT_BATTERY_NOT_LOW=" "
@@ -34,7 +40,8 @@ TEMP=`busybox getopt \
3440 -n $SCRIPTNAME \
3541 -o hs:p \
3642 --long script:,\
37- job-id:,pending:,\
43+ job-id:,pending,\
44+ cancel,cancel-all,\
3845period-ms:,network:,\
3946battery-not-low:,storage-not-low:,\
4047charging:,help,\
@@ -47,15 +54,17 @@ while true; do
4754 case " $1 " in
4855 -s | --script) OPT_SCRIPT=" $2 " ; shift 2;;
4956 --job-id) OPT_JOB_ID=" $2 " ; shift 2;;
50- -p | --pending) OPT_PENDING=" $2 " ; shift 2;;
57+ -p | --pending) OPT_PENDING=1; shift ;;
58+ --cancel) OPT_CANCEL=1; shift ;;
59+ --cancel-all) OPT_CANCEL_ALL=1; shift ;;
5160 --period-ms) OPT_PERIOD_MS=" $2 " ; shift 2;;
5261 --network) OPT_NETWORK=" $2 " ; shift 2;;
5362 --battery-not-low) OPT_BATTERY_NOT_LOW=" $2 " ; shift 2;;
5463 --storage-not-low) OPT_STORAGE_NOT_LOW=" $2 " ; shift 2;;
5564 --charging) OPT_CHARGING=" $2 " ; shift 2;;
5665 --trigger-content-flag) OPT_TRIGGER_CONTENT_FLAG=" $2 " ; shift 2;;
5766 --trigger-content-uri) OPT_TRIGGER_CONTENT_URI=" $2 " ; shift 2;;
58- -h | --help) show_usage;;
67+ -h | --help) show_usage;;
5968 --) shift ; break ;;
6069 esac
6170done
6675if [ -n " $OPT_SCRIPT " ]; then set -- " $@ " --es script " $OPT_SCRIPT " ; fi
6776if [ -n " $OPT_JOB_ID " ]; then set -- " $@ " --ei job_id " $OPT_JOB_ID " ; fi
6877if [ -n " $OPT_PENDING " ]; then set -- " $@ " --ez pending " $OPT_PENDING " ; fi
78+ if [ -n " $OPT_CANCEL " ]; then set -- " $@ " --ez cancel " $OPT_CANCEL " ; fi
79+ if [ -n " $OPT_CANCEL_ALL " ]; then set -- " $@ " --ez cancel_all " $OPT_CANCEL_ALL " ; fi
6980if [ -n " $OPT_PERIOD_MS " ]; then set -- " $@ " --ei period_ms " $OPT_PERIOD_MS " ; fi
7081if [ -n " $OPT_NETWORK " ]; then set -- " $@ " --es network " $OPT_NETWORK " ; fi
7182if [ -n " $OPT_BATTERY_NOT_LOW " ]; then set -- " $@ " --ez battery_not_low " $OPT_BATTERY_NOT_LOW " ; fi
0 commit comments