1

我已经为运行 Angstrom Linux 的嵌入式系统(Devkit8000,它是众所周知的 BeagleBoard 的克隆)编写了一个 c 程序。

该程序创建了几个线程,其中一个负责用连接到电路板上的相机拍照,现在第二个线程只将该图像移动到另一个路径。该程序应该全天运行,停止它的唯一方法是发送信号。

我编辑了 crontab 以在特定时间启动程序并在它必须停止时发送信号,问题是以这种方式启动程序会导致进程在运行一段时间后被终止,但是,如果我启动手动编程(通过命令行),它可以完美运行并且不会停止。

我不知道 crontab 和命令行之间这种不同行为的原因。我检查了系统日志,但没有发现任何有用的东西。我也读了一点,发现操作系统可以杀死一个进程,如果它使用这么多资源,但是这仅在一种情况下发生(crontab 与手动)没有意义......

关于发生了什么的任何线索?

先感谢您!

4

1 回答 1

0

The main difference is that running a job through cron invokes a non-interactive non-login shell. The effect of that depends on the default shell for your user. For example, if you are using Korn shell or Bash then your .profile will not be executed, as it would on an interactive login shell. Korn shell 88 will execute .kshrc (the $ENV file) but ksh93 will not. So, a good start might be to call your program from a script, after first "sourcing" your .profile file:

. $HOME/.profile

Failing that... When you say that the process is "killed", do you get such a message? If so, then that sounds like someone sending SIGKILL, i.e. kill -9. If not, then maybe you could run strace or ltrace to find out at what point it dies.

于 2012-05-29T11:31:41.127 回答