0

I know there are aready many questions about this topic, but no answer could solve my problem.

I use a Raspberry Pi B+ with the operating System Raspbian Jessie. The Raspberry is said to synchronize with an intern NTP server for the correct time. Further the Raspberry Pi shall play an audio file at a concrete time.

The command for the audio is saved in a script.

crontab -e

@reboot sudo ntpdate -s 10.0.5.3 @hourly sudo ntpdate -s 10.0.5.3 00 9 * * * /home/pi/script.sh 20 9 * * * /home/pi/script.sh 00 12 * * * /home/pi/script.sh 40 12 * * * /home/pi/script.sh 00 16 * * * /home/pi/script.sh

script.sh:
omxplayer audio.wav

The log shows following:
Jan 29 10:00:01 PiName CRON[726]: (root) CMD (sudo ntpdate -s 10.0.5.3) Jan 29 10:17:01 PiName CRON[757]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 29 11:00:01 PiName CRON[779]: (root) CMD (sudo ntpdate -s 10.0.5.3) Jan 29 11:17:02 PiName CRON[807]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Jan 29 12:00:01 PiName CRON[836]: (root) CMD (sudo ntpdate -s 10.0.5.3) Jan 29 12:00:01 PiName CRON[837]: (root) CMD (omxplayer audio.wav) Jan 29 12:00:03 PiName CRON[822]: (CRON) info (No MTA installed, discarding output)
The problem is that there is no sound played, if the time is reached. On another Raspberry Pi B with Raspbian wheezy, it works successful.

Thank you very much for every answer.

3
  • 1
    cron is clearly working. Presumably the "00 12 * * * /home/pi/script.sh" entry results in the "Jan 29 12:00:01 PiName CRON[837]: (root) CMD (omxplayer audio.wav)" line. Is that so?
    – joan
    Feb 1, 2016 at 13:33
  • Thats right. I don`t post the logs for all the times
    – user40830
    Feb 1, 2016 at 14:04
  • See also: raspberrypi.stackexchange.com/questions/40493/…
    – goldilocks
    Feb 1, 2016 at 14:57

3 Answers 3

0

Try adding a MTA (Mail Transport Agent) so you get local mail detailing the problem, e.g.

sudo apt-get install postfix

Generally cron job problems are down to a couple of reasons.

  • can't find the program to run as it's not in the default cron path - solution give the full path, e.g. /usr/bin/omxplayer rather than omxplayer
  • can't find the file to use as it's not in the default cron working directory - solution give the full path, e.g. /home/pi/audio.wav rather than audio.wav
7
  • Postfix is not related to CRON at all, and all the logs he needs are in syslog, btw Feb 1, 2016 at 14:28
  • @AlexeyVesnin What do you think (CRON) info (No MTA installed, discarding output) is indicating?
    – joan
    Feb 1, 2016 at 14:42
  • just the fact, that a copy of STDOUT could not be forwarded to MTA because there is no MTA installed. The command execution itself was completed before that message. Feb 1, 2016 at 15:30
  • @AlexeyVesnin No, you are wrong. cron sends diagnostic information as a mail message which is NOT in the syslog entry. In this case the mail message will identify why the cron job failed.
    – joan
    Feb 1, 2016 at 16:40
  • if you're SO essential about info/diag message, then - for a single local RPi - add ` 2>&1 | /usr/bin/logger -t MyCronJobNo1 ` Feb 1, 2016 at 18:49
1

You're lacking of three things in your script :

  • a shebang. You MUST invoke a shell first
  • PATH env variable should be set explicitly right after a shebang, or - try to source /home/user/dot-profile for your profile or a system-wide and your
  • use ONLY full paths, like /sbin/something args rather than just something args
1
-1

Check the system time. Raspbian Jessie doesn't ask by default on setting up the system. doesn't help if your out 12 hours like I am in NZ :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.