'cron' stops working after an Android start from CE

’cron’ stops working after an Android start from CE

I have seen that every time I start Android from CoreELEC and then return to CoreELEC with a normal restart, ‘cron’ stops working.

I have seen this because among the tasks that I run in ‘cron’ is this line that runs every 15 minutes:

*/15 * * * * date > /storage/cron_test

When I see that ‘cron’ has stopped working I have to edit the list of tasks ‘cron’ with crontab -e (without making any modification) to work again. This happens with any version of CoreELEC 9.x that I know.

Is there a solution to this problem?

This may not fix your problem but you should always use the full path in scripts like so:
* */15 * * * * /usr/bin/date > /storage/cron_test

But when I do a scheduled CoreELEC night reboot with ‘cron’, ‘cron’ continues to work fine.

I have modified the line

*/15 * * * * date > /storage/cron_test


*/15 * * * * /usr/bin/date > /storage/cron_test

then I started Android (latest stock firmware) from CoreELEC and then I went back to CoreELEC with a normal restart and CRON HAS STOPPED WORKING (and the LED of my KIII PRO has changed to red).

Can you post the result of command
systemctl status cron -l --no-pager

Now ‘cron’ does not work, it seems that if CoreELEC (the disk drive) is exposed to the Android stock firmware of KIII Pro, then ‘cron’ stops working. Maybe what happens is that ‘cron’ does not find the task file, but if I write ‘crontab -l’ it’s there. To solve the problem I have to edit ‘crontab -e’ changing something but leaving everything the same.

This is what it is:

CoreELEC:~ # systemctl status cron -l --no-pager
● cron.service - Cron daemon
   Loaded: loaded (/usr/lib/systemd/system/cron.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2015-01-01 01:00:25 CET; 4 years 4 months ago
  Process: 2723 ExecStartPre=/bin/mkdir -p /storage/.cache/cron/crontabs (code=exited, status=0/SUCCESS)
 Main PID: 2751 (crond)
   Memory: 104.0K
   CGroup: /system.slice/cron.service
           └─2751 /sbin/crond -f -S

Jun 22 13:11:53 CoreELEC systemd[1]: Starting Cron daemon...
Jan 01 01:00:25 CoreELEC systemd[1]: Started Cron daemon.
May 22 14:31:58 CoreELEC crond[2751]: time disparity of 2307631 minutes detected

As you can see cron IS running but your time is wrongly set. Maybe that’s the reason that entries are not executed.

From the source code:

  bb_error_msg("time disparity of %ld minutes detected", dt / 60);
  /* and we do not run any jobs in this case */

Maybe adding this to /storage/.config/autostart.sh would help. But setting time would be better :slight_smile:

systemctl restart cron

Thanks, I’ll check now

Adding ‘systemctl restart cron’ to ‘/storage/.config/autostart.sh’ has not solved the problem either. It seems that Android modifies something, which affects ‘cron’ and the color of the LED of the KIII PRO device.

How can I start ‘cron’ with a specific task file to add it to ‘/storage/.config/autostart.sh’?

I answer to myself. I have solved the problem of ‘cron’ by adding

crontab /storage/scripts/mycron.tab
systemctl restart cron



where mycron.tab has:

10 7 * * * /storage/scripts/reboot_oneminute.sh
20 7 * * * /storage/scripts/restart_xti3442.sh
30 7 * * * /storage/scripts/update_duckdns.sh
35 8/8 * * * /storage/scripts/load_epg_bg.sh
45 8/8 * * * /storage/scripts/load_epg_koala.sh
55 8/8 * * * /storage/scripts/load_epg_tdt.sh
*/15 * * * * /usr/bin/date > /storage/cron_test

Can you add this before crontab line
crontab -l >/storage/cron.list
and check what the result in file would be? Maybe your problem is that entries are lost somehow?

Bumping this old topic.
I’m running the latest version and I also see this issue.

I tried several actions, all with no effect:

  • restarting crontab service on the command line
  • stopping and starting crontab service on CoreElec user interface

The one that makes cron running again is openting crontab and force saving it.

I noticed that when crontab is saved, there’s a new cron.update file created under the folder
with root inside.

I tried to manually create this file, with the same content, and it is also not enough to fix it.

The only automated workaround I found that works is to add the following 2 lines to the autostart.sh script:
crontab -l > /storage/.config/cron.tab
crontab /storage/.config/cron.tab

There’s no need to restart the service.

This issue only happens when it reboots to Android and then back to CoreElec. If the reboot is only done from CoreElec to CoreElec it does not happen as long as cron is running before the reboot.
I run it on a Alfawise H96 Pro+ box.

modem2k, I just tried this and could replicate (on Beelink GS King X). Cron runs just fine after booting to Android and back to CoreELEC. Maybe there is some interaction with Android and CE on this specific box you have.

In the past I had problems with settings that run once waiting for CoreELEC to remember this on every boot or reboot (for example cron and zerotier). I don’t know what it depends on but sometimes CoreELEC forgets these settings or it doesn’t behave as expected.

My solution is to include in autostart.sh all the additional settings that all the services use in their operation without waiting for CoreELEC to remember them between two consecutive starts.

About | FAQ | Terms of Service | Privacy Policy | Legal Notice