title: Calling C++ script via Cron on Raspberry Pi
body: <p>I have a Raspberry Pi hooked up to an LED Matrix.  The matrix uses a script written in C++ to display an image (see <a href="https://github.com/Boomerific/rpi-rgb-led-matrix/" rel="nofollow noreferrer">https://github.com/Boomerific/rpi-rgb-led-matrix/</a>).  I want it to run periodically, and hoped to use Cron to do this.</p>
  <p>I created a script called run.sh:</p>
  <pre><code>#!/bin/sh
  cd home/pi/display16x32/rpi-rgb-led-matrix/
  sudo ./led-matrix 1 love.ppm
  </code></pre>
  <p>Then in sudo crontab -e, I added:</p>
  <pre><code>10-20/2 * * * * bash /home/pi/display16x32/rpi-rgb-led-matrix/run.sh
  </code></pre>
  <p>If I run the above commands in an LXTerm, the LED Matrix turns on and displays properly.  Cron, on the other hand, sends me polite emails to say that it ran the script, but the LED Matrix never turns on.  Instead, I get this message from Cron:</p>
  <blockquote>
  <p>Read image with 351x16</p>
  <p>pure virtual method called terminate called without an active exception</p>
  </blockquote>
  <p>What do I need to do to get Cron to actually activate the LED Matrix?</p>
  <p>Thanks in advance!</p>