Cron not working after reinstall

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.

See first post

Cheers, missed that.

  1. So what exactly is the current problem?

  2. I did notice you’re using an ampersand on the first line. That’s not necessary, since cron jobs are automatically run in the background.

@jappish84

happy reading you seem to need it never seen commands performed like that, if you feel insecure about cron still

https://www.google.se/search?q=how+does+cron+work&oq=how+does+cron+work

and if this all about getting Sickrage to run, then use this thread

I’m sorry if this comes out harsh but there seems to be a lot of confusion in this thread.

Have you even read the posts in this thread? Please point to what’s strange in my crontab -e

Posting a link to a wiki isn’t very helpful

Posting instructions on how to install Sickrage, when I have a working Sickbeard setup isn’t very helpful either.

@dillthedog
Problem is cron isn’t starting sickbeard @reboot, the first line in crontab -e that is

Everything else is running now it seems. I’ll try removing the ampersand and see if that makes a difference. As I’ve mentioned earlier, this crontab -e is just a copy-paste from the previously working configuration, that’s why I didn’t want to edit it, because I know it has been working for over a year

Threads this long have a tendency to lose focus. At least I know where to look now.

Thanks, I’ll try and keep that in mind, so I’ve removed the ampersand and now I do get an entry in the log:

Traceback (most recent call last):
  File "/home/osmc/SickBeard/SickBeard.py", line 36, in <module>
    from multiprocessing import freeze_support  # @UnresolvedImport
  File "/usr/lib/python2.7/multiprocessing/__init__.py", line 64, in <module>
    from multiprocessing.process import Process, current_process, active_children
  File "/usr/lib/python2.7/multiprocessing/process.py", line 312, in <module>
    _current_process = _MainProcess()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 309, in __init__
    self._authkey = AuthenticationString(os.urandom(32))
NotImplementedError: /dev/urandom (or equivalent) not found

Keep in mind, sickbeard is working if I simply start it manually

Debugging SickBeard is a little beyonf the remit of this forum, but I’ll make an educated guess that cron is starting it too early.

If correct, you have a couple of options:

Place your startup command in a wrapper script, that does something along the lines of:

while I can't ping google
  sleep 10
done
run Sickbeard

but that’s pretty hacky, IMO.

Since you want it to run at startup, I’d recommend you create a systemd .service file and enable it to run at startup. Here’s a thread about getting SickRage to run at startup:

since they’re related, it should be a good starting point.

Thanks, didn’t think of that. I should be able to try@reboot sleep 60 && run/SB to see if that’s what’s causing the problem?

he doesnt have to create the file its included in the git

all he have to do is modify the paths for it then move it and enable it

He’s using SickBeard, but I guess there’s also a systemd .service file for that.

The only thing to note is that in the thread I linked to, at least for SickRage, the .service file needed one extra line before it would run successfully in OSMC.

Thanks for pointing out that SB probably started too soon. I tried adding a 60 second delay to crontab as this was the fastest way to determine if that was the problem. Now SB starts at reboot.

I’ll probably replace it with a proper startup script later.

Thank again
Cheers