Can't get cronjob to work

I’ve installed Spotweb on my Raspberry Pi 3 running OSMC as per the guide on HTPC Guides. Most of the process went well (Spotweb was installed, I can retrieve headers and Sonarr and Couchpotato can pull NZBS from it) but I can’t get the cronjob to get to work for the life of me. As I am pretty much a beginner when it comes to Linux, I am not sure what to look for to troubleshoot the issue. I have tried:

  • making sure cron is installed (it is),
  • restarting crontab,
  • checking a simple reboot cronjob (*/2 * * * * /sbin/reboot) works (it did)
  • using full paths (see output below),
  • adding ‘root’ and ‘www-data’ as users at the beginning of the cronjob (before ‘php’),
  • including an empty line at the end of the job and
  • removing the logging part of the cronjob. However, retrieve.php is never run and the log as specified in the job is not created.

This is the current output of crontab -l:
*/5 * * * * /usr/bin/php /var/www/spotweb/retrieve.php > /var/www/spotweb/retrieve.log (I can’t copy the empty line at the end of the job, but it’s there.) It’s on 5 minutes for testing purposes; this will become */30 when the job finally works.

The output of sudo service crontab status:

● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled)
Active: active (running) since do 2016-05-05 18:00:28 EEST; 17min ago
Docs: man:cron(8)
Main PID: 18032 (cron)
CGroup: /system.slice/cron.service
└─18032 /usr/sbin/cron -f

mei 05 18:09:01 osmc CRON[18318]: pam_unix(cron:session): session closed fo…ot
mei 05 18:10:01 osmc CRON[18365]: pam_unix(cron:session): session opened fo…0)
mei 05 18:10:01 osmc CRON[18366]: (osmc) CMD (/usr/bin/php /var/www/spotweb…g)
mei 05 18:10:02 osmc CRON[18365]: (CRON) info (No MTA installed, discarding…t)
mei 05 18:10:02 osmc CRON[18365]: pam_unix(cron:session): session closed fo…mc
mei 05 18:15:01 osmc CRON[18519]: pam_unix(cron:session): session opened fo…0)
mei 05 18:15:01 osmc CRON[18520]: (osmc) CMD (/usr/bin/php /var/www/spotweb…g)
mei 05 18:15:01 osmc CRON[18519]: (CRON) info (No MTA installed, discarding…t)
mei 05 18:17:01 osmc CRON[18573]: pam_unix(cron:session): session opened fo…0)
mei 05 18:17:01 osmc CRON[18574]: (root) CMD ( cd / && run-parts --report…y)

The job is started but doesn’t actually fire and no log file is created in Spotweb’s directory. Is it related to the ‘No MTA installed’ message? Maybe a user permission issue? I’ll be happy to post more output if necessary. Thanks in advance for the help!

Checked the php/apache logs ? Maybe there is something there?

Do either of these help?

Thanks Sandbird and jb2cool. The first link gave me the info I needed. In the cronjob, I removed /var/www/spotweb/retrieve.log and added >/dev/null 2>&1 instead. Now the message about the missing MTA has disappeared from the status screen (there is no output that needs to be written anywhere!) and receive.php is executed as it should.

1 Like

lol, and i came back to the forum now to post just that.ahahaha. I realized i was using 2>1 on my crons as well…and forgot all about it.