脚本不在cron下运行,而是手动运行 [英] Script does not run under cron but runs manually

查看:175
本文介绍了脚本不在cron下运行,而是手动运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个开发人员为我写的脚本,它执行主要与ffmpeg相关的各种功能。当我使用

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

脚本运行正常,但当它运行通过cron时失败并显示错误代码127

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

有任何想法?

ls -l <​​/ code>在脚本显示:

ls -l on the script shows:


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

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


推荐答案

错误127意味着command not found。
很可能你在脚本中运行一些不在 cron 中的命令(你可以看到cron的PATH是什么,如果你看看<$

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).

您可以在shell中检查当前的PATH:

You can check your current PATH in the shell:

$ echo $PATH

然后将此路径复制到脚本的开头:

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

PATH=... 

而不是 ... ,你必须写上你先前的行 echo $ PATH )。

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

同时检查你是否有shebang行#! / sh 。如果你在命令行中启动不带 sh 的脚本,它是导入的。

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.

显示运行脚本的 / etc / crontab 行。

这篇关于脚本不在cron下运行,而是手动运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆