I have a cron job running a ruby script, here is crontab

* * * * * /usr/bin/ruby /home/pi/runbot.rb

permissions look like this

pi@pi $ ls -l runbot.rb
-rwxr-xr-x 1 pi pi 859 Aug 26 14:16 runbot.rb

More info

grep cron /var/log/syslog
Aug 26 17:21:42 pi crontab[5278]: (pi) BEGIN EDIT (pi)
Aug 26 17:21:54 pi crontab[5278]: (pi) REPLACE (pi)
Aug 26 17:21:54 pi crontab[5278]: (pi) END EDIT (pi)
Aug 26 17:22:01 pi /usr/sbin/cron[3217]: (pi) RELOAD (crontabs/pi)

Some more info

tail cron /var/log/syslog
Aug 26 17:23:01 pi /USR/SBIN/CRON[5289]: (CRON) info (No MTA installed, discarding output)
Aug 26 17:24:01 pi /USR/SBIN/CRON[5294]: (pi) CMD (ruby /home/pi/runbot.rb)
Aug 26 17:24:02 pi /USR/SBIN/CRON[5293]: (CRON) info (No MTA installed, discarding output)
Aug 26 17:25:01 pi /USR/SBIN/CRON[5298]: (pi) CMD (ruby /home/pi/runbot.rb)
Aug 26 17:25:02 pi /USR/SBIN/CRON[5297]: (CRON) info (No MTA installed, discarding output)

Pi model B, rasbian

  • what is the script about? sending mails? – Shan-Desai Aug 26 '16 at 18:51
  • I've verified that cron is calling the ruby script. If I comment almost all of the code out of the script it will run. Or if I just run the script from the command line it runs fine. It just won't run correctly when cron calls it – JanuskaE Aug 26 '16 at 19:40
  • OK add sleep 30; your script in crontab – Shan-Desai Aug 26 '16 at 19:41
  • This is definitely a path problem. I just can't figure out how to fix it. – JanuskaE Aug 26 '16 at 21:05

The problem was with my paths. Since I am using rvm with ruby I ran

rvm cron setup

from my working directory to setup my crontab.

I then added the path to my directory to the PATH in crontab made by rvm

Took a day to figure this out.


I think your error is that you have no mailer installed on the Pi.

I think maybe postfix can make thinks work here.

sudo apt install postfix

Also it would be better to analyze any errors in the script by using a subshell and sending the STDERR to STDOUT.

 * * * * * (/usr/bin/ruby /home/pi/runbot.rb) > /dev/null 2>&1

if you want to know what 2>&1 means here use This Reference

There might be other options too, instead of postfix maybe mailx can work too.

sudo apt install mailx

but you might want to check on that first

  • No, that is not the issue. – JanuskaE Aug 26 '16 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.