Michael Farah Michael Farah - 1 year ago 82
Linux Question

Script does not run under cron but runs manually

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*

Answer Source

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:


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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download