0

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

asked Aug 26, 2016 at 16:57
4
  • what is the script about? sending mails? Commented Aug 26, 2016 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 Commented Aug 26, 2016 at 19:40
  • OK add sleep 30; your script in crontab Commented Aug 26, 2016 at 19:41
  • This is definitely a path problem. I just can't figure out how to fix it. Commented Aug 26, 2016 at 21:05

2 Answers 2

3

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.

answered Aug 26, 2016 at 22:35
0

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

answered Aug 26, 2016 at 19:01
1
  • No, that is not the issue. Commented Aug 26, 2016 at 19:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.