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.

Ghanima
  • 15,958
  • 17
  • 65
  • 125

3 Answers3

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
Alexey Vesnin
  • 926
  • 10
  • 17
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
joan
  • 71,852
  • 5
  • 76
  • 108
-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 :)