Tutorial: Scheduled tasks in CoreELEC

This is strange. Do you create your scripts on windows? Can you upload the same script with the “wget” that doesn’t work so I have your unmodified one?

Also the output of:

which wget

For editing scripts I use Notepad ++ for Windows and nano for Linux.

Now the script without $ () works fine but I will continue using $ () because it never failed me. I do not know how to give an explanation, perhaps the epg download file of the website failed when I used the scrip without $ ().

Thanks for your comments

CoreELEC: ~ / .config / scripts # which wget
/ usr / bin / wget
CoreELEC: ~ / .config / scripts #

I get 400 Bad Request when script is DOS formatted.

1 Like

Alright. I never wanted you to not use them. If you feel comfortable use them I was just wondering if there is a bug.
And it’s probably like vpeter said if you have DOS format for scripts the newline character is wrong and only $() helps to avoid this.

1 Like

Thanks for finding out where the problem was.



Excellent guide which I saw just after I posted the problems below in General tab (now deleted for duplication.)

  1. I went into CE Settings and enabled crontab.
    Did #systemctl restart cron and also #systemctl status cron, and # crontab -l (returns nothing.)

So cron seems active…

Then #crontab -e to write a cronjob but get Abort menu via WinSCP login.

So what’s the problem?

  1. How can I install anacrontab to perform jobs that are not missed?

My reference:


Btw, I don’t plan to use any shell script; just a single command line which should be allowed, e.g.

"/etc/anacrontab "?

30 15 stop.kodi systemctl disable kodi.service

I want my Kodi to be switched off after a month or so on an x96mini box ( 30 days, with 15 min delay after boot.)
If there is an equivalent in crontab I would appreciate it, in case anacrontab cannot be installed !

No anacrontab.

Try to use putty for ssh conection and execute crontab -e.


Thanks, PuTTY did open the crontab.

Now, can you tell me if the command #systemctl disable service.kodi is correct?

Tried from PuTTY. This isn’t working: no effect !
I want to experiment with shutting down Kodi via SSH. I am assuming this will still keep the Linux part running?

Commands are stop and start.

systemctl stop kodi
systemctl start kodi

Oh thanks.
But why doesn’t the above command work, which I found from online at the Arch Linux wiki?

No idea :innocent:

What do you want to achieve? Stop kodi permanently? Then use paramater mask to disable service and unmask to enable back.


I would like to stop Kodi after some specified time period, even when I have rebooted the tv box in between. Think they call it a persistent command.

It’ll be nice to have kodi working again too, on demand.

The problem with the systemctl stop kodi command is that kodi is back after reboot.

How to do it?
Sorry I am a Linux noob. What is masking here?

You would need some scripting to achieve this what you want. Cron doesn’t support such functionality.

And why do you need to stop kodi?

Maybe you like my automatic daily restart using cron, maybe this solves some of your doubts, on Mondays and Fridays a full backup runs:

file /storage/.config/scripts/crontab.conf:

20 7 * * Mon /storage/.config/scripts/backup-and-reboot.sh
20 7 * * Tue systemctl reboot
20 7 * * Wed systemctl reboot
20 7 * * Thu systemctl reboot
20 7 * * Fri /storage/.config/scripts/backup-and-reboot.sh
20 7 * * Sat systemctl reboot
20 7 * * Sun systemctl reboot

file /storage/.config/scripts/backup-and-reboot.sh:

# stop main services
systemctl stop kodi
# systemctl stop service.softcam.oscam
# systemctl stop service.tvheadend42
systemctl stop service.tvheadend43
# systemctl stop entware
# save logs for entware servers
mv /opt/var/log/messages /opt/var/log/messages.old
mv /opt/var/log/zerotier-one.log /opt/var/log/zerotier-one.log.old
# full backup
mv /media/EXT-HDD/Backups/full-backup.tar /media/EXT-HDD/Backups/full-backup.old.tar
tar cvf  /media/EXT-HDD/Backups/full-backup.tar /storage/.kodi /storage/.cache /storage/.config /storage/.opt
systemctl reboot

All of this is launched from /storage/.config/autostart.sh with the command:
crontab /storage/.config/scripts/crontab.conf

You can use commas in crontab timers:
20 7 * * 1,5 /storage/.config/scripts/backup-and-reboot.sh
20 7 * * 2,3,4,6,7 systemctl reboot

1 Like

Is there anyway I can bind a script to run with a keyboard press (F1-F12, for instance)?
I want to reboot from nand, to boot to android and it’s a fairly simple command, just need help tying it to a keyboard press.

You don’t need 3 commands for this particular case of epg updating. The same result could be reached with just one:

wget -q -O - http://url_of_your_guide/guide.xml.gz | gunzip > /storage/path_to_your_guide_file/guide.xml

And it could be placed directly to crontab. No additional directories and scripts needed.