Cron not working after reinstall

ok, so my SD card broke and I had to reinstall OSMC. Tried configuring everything as it was before but can’t seem to get my crontab working and I’m not sure how to find out what’s wrong.

crontab entrys are running fine if I run them manually but are not run by cron

crontab -l

http://paste.osmc.io/ozufexotic.md

Not sure what this below means, is cron active?

`osmc@Trdck:~$ sudo service crontab status

* crontab.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

osmc@Trdck:~$ ps aux | grep cron

root       192  0.0  0.5   3476  2000 ?        Ss   20:25   0:00 /usr/sbin/cron -f
osmc       636  0.0  0.4   2656  1496 pts/0    S+   21:01   0:00 grep cron
1 Like

sudo apt-get install cron

its not installed by default

Yeah, I know, I have installed it, otherwise crontab -l wouldn’t work

Hi,

Sorry had a mind blank than, should be installed via the my osmc app store.

if you’ve installed via apt-get, remove and install from the store.

Thanks Tom.

thanks, will try that instead!

What’s so spiffy about the OSMC version? Is it based on something else, like fcron, or what?

And here’s the cause of the OP’s problems:

osmc@osmc:~$ sudo systemctl status cron
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; disabled)
   Active: active (running) since Sun 2017-06-04 23:24:19 BST; 7s ago
     Docs: man:cron(8)
 Main PID: 9145 (cron)
   CGroup: /system.slice/cron.service
           └─9145 /usr/sbin/cron -f

Jun 04 23:24:19 osmc systemd[1]: Started Regular background program processing daemon.
Jun 04 23:24:19 osmc cron[9145]: (CRON) INFO (pidfile fd = 3)
Jun 04 23:24:19 osmc cron[9145]: (CRON) INFO (Running @reboot jobs)

The service isn’t called crontab.

2 Likes

The OSMC version of cron is simply cron.

We don’t bundle it by default but all cron-app-osmc does is depend on cron and as such bring it in from upstream repo and add a couple of files to allow control from My OSMC.

Ok, so I didn’t really think removing and installing through myOSMC would make any difference because i’ve installed it using apt-get on my other rpi’s.

I installed it, and saw that I was on the March version so I went ahead and updated the OS aswell. That didn’t go well, bunch of errors. I’m actually starting to think there’s a HW fault with this old pi. The power LED is acting strange, sometimes it kinda tries to lit up and fails, sometimes it makes it, but I get no picture…

I’ve tried a known working power adapter and it behaves the same.

Will give it another clean install… if that doesn’t work I guess I’ll have to replace it.

Sorry just to clarify, is this with a new sd card or was a corrupt install and just a reinstall over the old card?

if its the latter I’d try replacing the sd card, before the pi.

Thanks Tom.

I replaced the SD card with a new one. At first the rpi didn’t light up at all, so this time I replaced the PSU and cable and it booted up. Whats still odd is that I get to the point of “installing files”, then it reboots and get’s stuck. After a manual reboot it’s back to installing files…

I’ll take a closer look when I have more time.

Thanks

Ok so something got messed up and somehow the SD card didn’t have write permissions enabled. I reformatted and I have now installed OSMC, fully updated.

I’m still having the same issue as before though. My entrys run fine if I run them as user osmc, but if I run them like this:

osmc@Trdck:~$ cron python /home/osmc/SickBeard/SickBeard.py

I get this

cron: can't open or create /var/run/crond.pid: Permission denied

What can I do to get this working again?

Thanks

Generally, you need to edit the crontab file using crontab -e and define when you would like the job to run.

You need to research how cron works. What you are trying to do makes no sense.

Normal cron usage is that you add lines to your crontab using crontab -e, and then the commands run via the schedule set in the crontab.

EDIT: I did a quick google for you: CronHowto - Community Help Wiki

The lines are added using crontab -e

@bmillham
not sure what doesn’t make sense. Like I wrote before, this is not the first time I use cronjobs. This exact setup has been working for over a year until my SD card crashed.

I’ve never had permission issues before. After each reinstall or new configuration I’d just run sudo apt-get install cron

add the lines with crontab -e and never had issues. I’m running cron this way on 3 other rpi’s running OSMC atm and they all work… sooo…

@dillthedog Of course! Service isn’t called crontab, here’s my output running

osmc@Trdck:~$ sudo systemctl status cron
* cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled)
   Active: active (running) since Tue 2017-06-06 23:17:43 CEST; 1min 10s ago
     Docs: man:cron(8)
 Main PID: 205 (cron)
   CGroup: /system.slice/cron.service
           `-205 /usr/sbin/cron -f

Jun 06 23:17:43 Trdck systemd[1]: Starting Regular background program processing daemon...
Jun 06 23:17:43 Trdck systemd[1]: Started Regular background program processing daemon.
Jun 06 23:17:44 Trdck cron[205]: (CRON) INFO (pidfile fd = 3)
Jun 06 23:17:44 Trdck cron[205]: (CRON) INFO (Running @reboot jobs)
Jun 06 23:17:44 Trdck CRON[209]: pam_unix(cron:session): session opened for user osmc by (uid=0)
Jun 06 23:17:44 Trdck CRON[216]: (osmc) CMD (python /home/osmc/SickBeard/SickBeard.py &)
Jun 06 23:17:44 Trdck CRON[209]: pam_unix(cron:session): session closed for user osmc

If I run nice perl /home/osmc/sorttv/sorttv.pl the program runs fine

If I run osmc@Trdck:~$ cron /usr/bin/nice /usr/bin/perl /home/osmc/sorttv/sorttv.pl I get
cron: can't open or create /var/run/crond.pid: Permission denied

I’ll say it again, this makes no sense. This is not how you use cron. Period. Please read the link I provided on the proper use of cron. It’s very simple, 1) Edit crontab, 2) Wait for the job to run. That’s it.

Explain to me why you are trying to run the quoted command.

I think you misinterpreted me. Maybe my post isn’t clear enough.

I tried to run that command to try and figure out WHY my crontab isn’t working.

This is how I set up everyting, in order:

  1. install OSMC
  2. update OSMC to latest version
  3. install cron
  4. install sickbeard and sorttv
  5. test so sickbeard and sorttv work - they do
  6. in terminal as user osmc crontab -e
  7. pasted these lines http://paste.osmc.io/ozufexotic.md
  8. reboot

cron isn’t running any of the entries inside my crontab and that’s why I’m writing this post and trying to figure out why it’s not running. If I understand it correctly, running osmc@Trdck:~$ cron /usr/bin/nice /usr/bin/perl /home/osmc/sorttv/sorttv.pl I run the command as cron would and it tells me that cron is having permission problems

The link you provided tells me that the first thing to check when something isn’t running as it’s supposed to is to check /var/log/syslog but that isn’t present in OSMC

sorry for a lot of edits

Ok, that makes more sense now. You can’t run the job manually like you were trying.

Modify your crontab so each line end with a >>/home/osmc/sickbeard.log 2>&1

For example:

15 * * * * /usr/bin/nice /usr/bin/perl /home/osmc/sorttv/sorttv.pl >>/home/osmc/sickbeard.log 2>&1

After the job is supposed to run, check the sickbeard.log file for errors.

Thanks,

OK so I can see the output from sorttv in the log and it’s running fine. And even though I can’t see anything in the log from the find commands, I’d say they’ve run because all empty directories that sorttv leaves behind are gone.

Is @reboot the problem here? It shouldn’t be, like I’ve mentioned, it’s been working fine before.

We’re shooting blindfold here since I believe we haven’t ever seen your crontab, so please show us using crontab -l.

It tells me that running cron under user osmc doesn’t work. But cron doesn’t normally run under osmc (it runs under root), so the test isn’t particularly helpful.

So is it running fine? Because you then go on to say:

What problem are we talking about?

I think it’s reasonable to surmise that cron is working and that any problems you have lie with the command(s) in your crontab.