If you want to use cron in Termux, you need to follow these simple steps:
Run the following command to update Termux packages:
pkg update
Install the cronie package by running this command:
pkg install cronie
Use the crontab -e command to set up a cron job. For example, if you want to run a script named my-script.sh every hour, use this syntax:
0 * * * * /data/data/com.termux/files/home/my-script.sh
Check cron tasks: You can check all the cron tasks you have set up using the command:
crontab -l
Every time you start Termux, you need to start the cron service by running the command:
sv up crond
For disable, close terminal or use:
sv down crond
To check the status of the cron service, run this command:
sv status crond
run: crond: (pid 6408) 35s; run: log: (pid 6407) 35s
That's it! By following these simple steps, you can set up and use cron in Termux to automate your tasks.
Use random time for cron (120 sec)
* * * * * sleep $((RANDOM \% 120)) && sh /data/data/com.termux/files/home/testfind.sh