1

I have a script that a developer wrote for me which performs various functions mainly related to ffmpeg. When I run the script manually using

sh /home/site/rawvids/encode.sh > /home/site/rawvids/log.txt

The script runs fine but when it runs through cron it fails with error code 127

Any ideas?

ls -l on the script shows:

-rwxrwxrwx 1 site nobody 3786 Jul 23 17:07 /home/site/rawvids/encode.sh*

Michael Farah
  • 325
  • 1
  • 7
  • 20

3 Answers3

2

Error 127 means "command not found". It is likely that you run in the script some commands that are not in the of cron (you can see what cron's PATH is, if you look at /etc/crontab).

You can check your current PATH in the shell:

$ echo $PATH

And then copy this PATH to the beginning of the script:

PATH=... 

Instead of ... you must write the line that you've got earlier (using echo $PATH).

Also check if you have shebang line #!/bin/sh at the beginning of the script. It is import if you start script without sh in the command line.

Also it would be great if you could show us the line from /etc/crontab that runs the script.

Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
0

Most likely you're either depending on an environment variable which isn't set for cron (I'm not sure if cron uses any?) or the permissions cron is running under are wrong. If you're piping the output like that in the cron version, does it get any output?

Brendan Long
  • 53,280
  • 21
  • 146
  • 188
0

same ..., well i just can stand these path issues , i set up a symbolic link to the ffprobe path or whatever is missing , something like

ln -s /usr/local/bin/ffprobe /home/ec2-user/.rvm/rubies/ruby-2.3.0/bin/ffprobe