cron launching but not executing script - Ask Ubuntu


i setup crontab crontab -e , checked saved crontab -l:

*/10 6-8 * 1-11 1 /home/asarluhi/documents/scripts/monday.sh 

the content of monday.sh is:

#!/bin/bash  ruby ~/documents/scripts/monday_task.rb >> ~/documents/scripts/monday 

monday_task.rb ruby script web scrapes data, long report here, there no mistakes in it. monday simple empty text file,
the script working fine when launched shell.

i looked @ var/log/syslog , found following entries:

nov  7 07:55:01 satellite-l50-a-161 cron[6984]: (root) cmd (command -v debian-sa1 > /dev/null && debian-sa1 1 1) nov  7 08:00:01 satellite-l50-a-161 cron[7032]: pam_ecryptfs: skipping automatic ecryptfs mount nov  7 08:00:01 satellite-l50-a-161 cron[7033]: (asarluhi) cmd (/home/asarluhi/documents/scripts/monday.sh) nov  7 08:00:01 satellite-l50-a-161 cron[7031]: (asarluhi) mail (mailed 1 byte of output; got status 0x00ff, #012) nov  7 08:00:01 satellite-l50-a-161 cron[7038]: pam_ecryptfs: skipping automatic ecryptfs unmount nov  7 08:00:43 satellite-l50-a-161 anacron[6485]: job `cron.daily' terminated nov  7 08:00:43 satellite-l50-a-161 anacron[6485]: normal exit (1 job run) nov  7 08:05:01 satellite-l50-a-161 cron[7112]: (root) cmd (command -v debian-sa1 > /dev/null && debian-sa1 1 1) nov  7 08:10:01 satellite-l50-a-161 cron[7141]: pam_ecryptfs: skipping automatic ecryptfs mount nov  7 08:10:01 satellite-l50-a-161 cron[7142]: (asarluhi) cmd (/home/asarluhi/documents/scripts/monday.sh) nov  7 08:10:01 satellite-l50-a-161 cron[7140]: (asarluhi) mail (mailed 1 byte of output; got status 0x00ff, #012) nov  7 08:10:01 satellite-l50-a-161 cron[7147]: pam_ecryptfs: skipping automatic ecryptfs unmount nov  7 08:15:01 satellite-l50-a-161 cron[7206]: (root) cmd (command -v debian-sa1 > /dev/null && debian-sa1 1 1) nov  7 08:17:01 satellite-l50-a-161 cron[7221]: (root) cmd (   cd / && run-parts --report /etc/cron.hourly) ... 

as can notice, cron jobs start @ 8:00 rather @ 6:00 in crontable.
script launched nothing written in ~/documents/scripts/monday
read in cron not running scripts previous askubuntu question stderr should end in system mail, there not directories named after user name in /var/mail/, found nothing.

it looks executable ruby not in cron's path, need use full path executable.

change monday.sh script from:

#!/bin/bash ruby ~/documents/scripts/monday_task.rb >> ~/documents/scripts/monday 

to:

#!/bin/bash /home/asarluhi/.rvm/rubies/ruby-2.3.1/bin/ruby /home/asarluhi/documents/scripts/monday_task.rb >> /home/asarluhi/documents/scripts/monday 

as syslog demonstrates monday.sh script being run on time absolute path-names answer. per op comment ruby has prefixed absolute path-name.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User