2

I've inherited someone else's monster of a BASH script. The script was written in such a way that it uses a ridiculous amount of memory (around 1GB). I can run it from a shell with out issue, but if I run it from cron I crashes with a sig fault.

Apart from digging into the poorly commented behemoth, is there a way to run it from cron with out running into the sig fault?

Cheers,

Steve

4

3 回答 3

2

When you run something using cron you'll encounter issues with the environment variables being different or simply not set as compared to your own variables when you manually execute. Often things like the PATH aren't set properly when cron executes something, so it's important to supply full paths to executables within the script, even for things such as perl or common commands that you thing should be found in the default PATH. Without more info it's hard to speculate on what precisely the problem is.

于 2008-11-05T17:40:32.860 回答
2

Is it expecting to be connected to a tty or have an open stdin? Try redirecting a file of something random to it as inout when it's running from cron?

What segfaults? Bash, or something it calls?

Any hints from the core file as to what the problem is?

于 2008-11-05T17:41:36.087 回答
-1

尝试确保 stdout 和 stderr 有地方可去

/path/to/bigscript.sh &> /dev/null

[编辑] 您可能想要使用 /dev/null 以外的文件,尤其是在调试模式下运行它时;)

如此庞大,如果在调试中运行会有所帮助,我不会,但您可以尝试。在 bash 中,它是 '-x' 选项,您可以将其放入 shebang 中。

正如在其他答案中所说,它很有可能是一个环境变量。

于 2008-11-05T18:35:51.687 回答