'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?