Termux-app: Can someone explain how to set a cronjob on Termux?

Created on 14 Apr 2019  路  4Comments  路  Source: termux/termux-app

I have added the following command to crontab -e

0 14 * * * some command

How can I check if it's running, usually I would do this via ps -a on a Linux install.

thanks!

Most helpful comment

thanks @xeffyr one last question

in #14 there's this answer

So the following is all you really need within bashrc, or preferably bash_profile if bash_profile works on your termux install:

if ! pgrep -f "crond" >/dev/null; then
echo "[Starting crond...]" && crond && echo "[OK]"
else
echo "[crond is running]"
fi

The reason why bash_profile is preferred, bash_profile is called once during initial login, versus bashrc upon each shell opening. (Will save a few CPU cycles to use bash_profile.)

If i add this i wont need to manually start crond right?

All 4 comments

Create crontab and then manually launch crond. There no init system and everything should be started manually.


How can I check if it's running

pidof crond

thanks @xeffyr one last question

in #14 there's this answer

So the following is all you really need within bashrc, or preferably bash_profile if bash_profile works on your termux install:

if ! pgrep -f "crond" >/dev/null; then
echo "[Starting crond...]" && crond && echo "[OK]"
else
echo "[crond is running]"
fi

The reason why bash_profile is preferred, bash_profile is called once during initial login, versus bashrc upon each shell opening. (Will save a few CPU cycles to use bash_profile.)

If i add this i wont need to manually start crond right?

Yes, this should work.

Was this page helpful?
0 / 5 - 0 ratings