Trying to start a script at boot

I set up tvheadend for my usb tuner, then set up my channels at zap2it to use with zap2xml to grab the epg info. It works when run manually from a terminal, but I’m having a hell of a time trying to get it to run at boot. Everything I read about crontab makes it sound so easy… even in posts specifically about setting up zap2xml. The best I’ve been able to get out of it… it creates the cache folder… but it’s empty, and it never creates the icon folder… let alone fill it up. And of course… no xmltv.xml at the end of it all. Blah.

Here’s my script:

#!/bin/bash cd /home/osmc/zap2xml /usr/bin/perl -u [user@email] -p [password] -d 7 -A -D -i icons -I -o xmltv.xml

I then type…

crontab -e

And add…

@reboot /home/osmc/

I’ve even tried ‘@daily’, ‘@hourly’, and even ‘0 * * * *’ for hourly. Nothing works… it’s all the same. Cron doesn’t like me. :stuck_out_tongue:

show the output of ls -lah /home/osmc
And check sudo journalctl _COMM=cron

thanks fzinken… it seems I didn’t wait long enough… the once an hour cronjob just had success.

0 * * * * /home/osmc/

But I’d rather have it just run at boot. I don’t want a set schedule/day, as I don’t leave the pi powered on 24/7. Grabbing the epg at boot would be better. The @reboot didn’t work though.

Here’s the outputs of the infos you mentioned…

osmc@osmc:~$ ls -lah /home/osmc total 76K drwxr-xr-x 11 osmc osmc 4.0K Sep 18 20:09 . drwxr-xr-x 3 root root 4.0K Dec 31 1969 .. -rw------- 1 osmc osmc 1.7K Sep 18 20:36 .bash_history -rw-r--r-- 1 osmc osmc 220 Nov 12 2014 .bash_logout -rw-r--r-- 1 osmc osmc 3.5K Nov 12 2014 .bashrc lrwxrwxrwx 1 osmc osmc 42 Sep 18 16:26 .emulationstation -> /opt/retropie/configs/all/emulationstation drwxr-xr-x 3 osmc osmc 4.0K Sep 18 16:14 .hts -rwxr-xr-x 1 osmc osmc 5.5K Sep 18 16:18 drwxr-xr-x 7 osmc osmc 4.0K Dec 31 1969 .kodi drwxr-xr-x 2 osmc osmc 4.0K Aug 30 04:15 Movies drwxr-xr-x 2 osmc osmc 4.0K Aug 30 04:15 Music drwxr-xr-x 2 osmc osmc 4.0K Aug 30 04:15 Pictures -rw-r--r-- 1 osmc osmc 675 Nov 12 2014 .profile drwxr-xr-x 6 osmc osmc 4.0K Sep 18 16:27 RetroPie drwxr-xr-x 7 osmc osmc 4.0K Sep 18 16:35 RetroPie-Setup -rw-r--r-- 1 osmc osmc 66 Sep 18 18:03 .selected_editor drwxr-xr-x 2 osmc osmc 4.0K Sep 18 19:09 TV Shows drwxr-xr-x 4 osmc osmc 4.0K Sep 18 21:00 zap2xml -rwxr--r-- 1 osmc osmc 135 Sep 18 20:09

osmc@osmc:~$ sudo journalctl _COMM=cron -- Logs begin at Sun 2016-09-18 20:37:32 PDT, end at Sun 2016-09-18 21:03:29 PDT Sep 18 20:37:33 osmc cron[391]: (CRON) INFO (pidfile fd = 3) Sep 18 20:37:33 osmc cron[391]: (CRON) INFO (Running @reboot jobs) Sep 18 21:00:01 osmc CRON[1307]: pam_unix(cron:session): session opened for user Sep 18 21:00:01 osmc CRON[1308]: (osmc) CMD (/home/osmc/

So… how do I get this to just run at boot? :stuck_out_tongue:


I’m thinking maybe the script was being called too early after boot for perl to be usable(?). I remember seeing a post somewhere where they added ‘wait 120’ before executing the script. I’ll try that later with @reboot.

Sounds like a plan especially as the hourly worked.

That worked… lol. I gave it 5 minutes before executing. I was a little miffed though… it looked as if it didn’t work… until I refreshed the folder. :stuck_out_tongue:

@reboot sleep 300 && /home/osmc/

That’s a hell of a lot easier than someone else’s thread, where they wound up having to set up the perl environment to their home directory or some damn chit… lol. :stuck_out_tongue: